diff options
-rw-r--r-- | engines/sci/decompressor.cpp | 8 | ||||
-rw-r--r-- | engines/sci/decompressor.h | 2 | ||||
-rw-r--r-- | engines/sci/detection.cpp | 20 | ||||
-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 | ||||
-rw-r--r-- | engines/sci/sfx/iterator.cpp | 8 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_codecs.cpp | 1 | ||||
-rw-r--r-- | engines/scumm/player_v2a.cpp | 1 | ||||
-rw-r--r-- | engines/scumm/sound.cpp | 2 |
15 files changed, 66 insertions, 72 deletions
diff --git a/engines/sci/decompressor.cpp b/engines/sci/decompressor.cpp index 6ed43e248e..239c6cae03 100644 --- a/engines/sci/decompressor.cpp +++ b/engines/sci/decompressor.cpp @@ -594,7 +594,7 @@ void DecompressorLZW::reorderView(byte *src, byte *dest) { // Leaf node #define LN(pos, value) ((value) | HUFFMAN_LEAF), -static int length_tree[] = { +static const int length_tree[] = { BN(0, 1, 2) BN(1, 3, 4) BN(2, 5, 6) BN(3, 7, 8) BN(4, 9, 10) BN(5, 11, 12) LN(6, 1) @@ -606,7 +606,7 @@ static int length_tree[] = { 0 // We need something witout a comma at the end }; -static int distance_tree[] = { +static const int distance_tree[] = { BN(0, 1, 2) BN(1, 3, 4) BN(2, 5, 6) // @@ -649,7 +649,7 @@ static int distance_tree[] = { 0 // We need something witout a comma at the end }; -static int ascii_tree[] = { +static const int ascii_tree[] = { BN(0, 1, 2) BN(1, 3, 4) BN(2, 5, 6) BN(3, 7, 8) BN(4, 9, 10) BN(5, 11, 12) BN(6, 13, 14) BN(7, 15, 16) BN(8, 17, 18) BN(9, 19, 20) BN(10, 21, 22) BN(11, 23, 24) @@ -798,7 +798,7 @@ int DecompressorDCL::unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, } -int DecompressorDCL::huffman_lookup(int *tree) { +int DecompressorDCL::huffman_lookup(const int *tree) { int pos = 0; int bit; diff --git a/engines/sci/decompressor.h b/engines/sci/decompressor.h index a01434d9fb..9f6e7908cc 100644 --- a/engines/sci/decompressor.h +++ b/engines/sci/decompressor.h @@ -178,7 +178,7 @@ public: protected: int unpackDCL(byte *dest); - int huffman_lookup(int *tree); + int huffman_lookup(const int *tree); }; #ifdef ENABLE_SCI32 diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index bf90d15604..b928776dcb 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -3357,7 +3357,7 @@ static const struct SciGameDescription SciGameDescriptions[] = { * The fallback game descriptor used by the SCI engine's fallbackDetector. * Contents of this struct are to be overwritten by the fallbackDetector. */ -static SciGameDescription g_fallbackDesc = { +static SciGameDescription s_fallbackDesc = { { "", "", @@ -3463,23 +3463,23 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl return 0; // Set some defaults - g_fallbackDesc.desc.gameid = "sci"; - g_fallbackDesc.desc.extra = ""; - g_fallbackDesc.desc.language = Common::UNK_LANG; - g_fallbackDesc.desc.platform = exePlatform; - g_fallbackDesc.desc.flags = ADGF_NO_FLAGS; - g_fallbackDesc.version = SCI_VERSION_0; + s_fallbackDesc.desc.gameid = "sci"; + s_fallbackDesc.desc.extra = ""; + s_fallbackDesc.desc.language = Common::UNK_LANG; + s_fallbackDesc.desc.platform = exePlatform; + s_fallbackDesc.desc.flags = ADGF_NO_FLAGS; + s_fallbackDesc.version = SCI_VERSION_0; printf("If this is *NOT* a fan-modified version (in particular, not a fan-made\n"); printf("translation), please, report the data above, including the following\n"); printf("version number, from the game's executable:\n"); // Try to parse the executable version - if (getSciVersionFromString(exeVersionString, &g_fallbackDesc.version, g_fallbackDesc.desc.platform)) { + if (getSciVersionFromString(exeVersionString, &s_fallbackDesc.version, s_fallbackDesc.desc.platform)) { printf("Detected version: %s, parsed SCI version: %s\n", - exeVersionString.c_str(), versionNames[g_fallbackDesc.version]); + exeVersionString.c_str(), versionNames[s_fallbackDesc.version]); - return (const ADGameDescription *)&g_fallbackDesc; + return (const ADGameDescription *)&s_fallbackDesc; } else { printf("Couldn't parse the interpreter version: %s (by executable scan)\n", exeVersionString.c_str()); 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, diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index 96bdee84b5..6992107b8a 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -1368,9 +1368,9 @@ TeeSongIterator::~TeeSongIterator() { int TeeSongIterator::nextCommand(byte *buf, int *result) { - static int ready_masks[2] = {TEE_LEFT_READY, TEE_RIGHT_READY}; - static int active_masks[2] = {TEE_LEFT_ACTIVE, TEE_RIGHT_ACTIVE}; - static int pcm_masks[2] = {TEE_LEFT_PCM, TEE_RIGHT_PCM}; + static const int ready_masks[2] = {TEE_LEFT_READY, TEE_RIGHT_READY}; + static const int active_masks[2] = {TEE_LEFT_ACTIVE, TEE_RIGHT_ACTIVE}; + static const int pcm_masks[2] = {TEE_LEFT_PCM, TEE_RIGHT_PCM}; int i; int retid; @@ -1497,7 +1497,7 @@ int TeeSongIterator::nextCommand(byte *buf, int *result) { } Audio::AudioStream *TeeSongIterator::getAudioStream() { - static int pcm_masks[2] = {TEE_LEFT_PCM, TEE_RIGHT_PCM}; + static const int pcm_masks[2] = {TEE_LEFT_PCM, TEE_RIGHT_PCM}; int i; for (i = TEE_LEFT; i <= TEE_RIGHT; i++) diff --git a/engines/scumm/imuse_digi/dimuse_codecs.cpp b/engines/scumm/imuse_digi/dimuse_codecs.cpp index e4bce827c4..22796f3152 100644 --- a/engines/scumm/imuse_digi/dimuse_codecs.cpp +++ b/engines/scumm/imuse_digi/dimuse_codecs.cpp @@ -22,7 +22,6 @@ * $Id$ */ - #include "common/scummsys.h" #include "common/endian.h" #include "common/util.h" diff --git a/engines/scumm/player_v2a.cpp b/engines/scumm/player_v2a.cpp index 719328d23f..73fc8d1b8a 100644 --- a/engines/scumm/player_v2a.cpp +++ b/engines/scumm/player_v2a.cpp @@ -23,7 +23,6 @@ * */ - #include "engines/engine.h" #include "scumm/player_v2a.h" #include "scumm/scumm.h" diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 4f9c02322a..f1be5e0b17 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -1292,7 +1292,7 @@ int ScummEngine::readSoundResource(int idx) { } // Adlib MIDI-SYSEX to set MIDI instruments for small header games. -static byte ADLIB_INSTR_MIDI_HACK[95] = { +static const byte ADLIB_INSTR_MIDI_HACK[95] = { 0x00, 0xf0, 0x14, 0x7d, 0x00, // sysex 00: part on/off 0x00, 0x00, 0x03, // part/channel (offset 5) 0x00, 0x00, 0x07, 0x0f, 0x00, 0x00, 0x08, 0x00, |