~ubuntu-branches/ubuntu/utopic/sgt-puzzles/utopic

« back to all changes in this revision

Viewing changes to towers.c

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2013-06-30 03:20:16 UTC
  • mfrom: (1.2.13)
  • Revision ID: package-import@ubuntu.com-20130630032016-v8xqt6vtg6tgs420
Tags: 9872-1
* New upstream version
  - Add an explicit -lm to the link lines in Makefile.gtk (Closes: #713476)
  - Add Undead by Steffen Bauer, an implementation of 'Haunted Mirror Maze'
  - Add Unruly by Lennard Sprong, an implementation of a puzzle usually
    called 'Tohu wa Vohu'
* Add DEP-3 headers to patches
* pearl: Require width or height to be at least 6 for Tricky
  (Closes: #667963)
* debian/watch: Update ViewVC URL regex
* Add 'sgt-' prefix to all command names and remove 'game' suffix, but
  retain symlinks under the old names (see #684193)
* Use upstream short descriptions in English manual pages and package
  description
* Update German translation, thanks to Helge Kreutzmann

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
    sfree(params);
168
168
}
169
169
 
170
 
static game_params *dup_params(game_params *params)
 
170
static game_params *dup_params(const game_params *params)
171
171
{
172
172
    game_params *ret = snew(game_params);
173
173
    *ret = *params;                    /* structure copy */
195
195
    }
196
196
}
197
197
 
198
 
static char *encode_params(game_params *params, int full)
 
198
static char *encode_params(const game_params *params, int full)
199
199
{
200
200
    char ret[80];
201
201
 
206
206
    return dupstr(ret);
207
207
}
208
208
 
209
 
static config_item *game_configure(game_params *params)
 
209
static config_item *game_configure(const game_params *params)
210
210
{
211
211
    config_item *ret;
212
212
    char buf[80];
232
232
    return ret;
233
233
}
234
234
 
235
 
static game_params *custom_params(config_item *cfg)
 
235
static game_params *custom_params(const config_item *cfg)
236
236
{
237
237
    game_params *ret = snew(game_params);
238
238
 
242
242
    return ret;
243
243
}
244
244
 
245
 
static char *validate_params(game_params *params, int full)
 
245
static char *validate_params(const game_params *params, int full)
246
246
{
247
247
    if (params->w < 3 || params->w > 9)
248
248
        return "Grid size must be between 3 and 9";
608
608
 * Grid generation.
609
609
 */
610
610
 
611
 
static char *new_game_desc(game_params *params, random_state *rs,
 
611
static char *new_game_desc(const game_params *params, random_state *rs,
612
612
                           char **aux, int interactive)
613
613
{
614
614
    int w = params->w, a = w*w;
803
803
 * Gameplay.
804
804
 */
805
805
 
806
 
static char *validate_desc(game_params *params, char *desc)
 
806
static char *validate_desc(const game_params *params, const char *desc)
807
807
{
808
808
    int w = params->w, a = w*w;
809
809
    const char *p = desc;
868
868
    return NULL;
869
869
}
870
870
 
871
 
static game_state *new_game(midend *me, game_params *params, char *desc)
 
871
static game_state *new_game(midend *me, const game_params *params,
 
872
                            const char *desc)
872
873
{
873
874
    int w = params->w, a = w*w;
874
875
    game_state *state = snew(game_state);
931
932
    return state;
932
933
}
933
934
 
934
 
static game_state *dup_game(game_state *state)
 
935
static game_state *dup_game(const game_state *state)
935
936
{
936
937
    int w = state->par.w, a = w*w;
937
938
    game_state *ret = snew(game_state);
964
965
    sfree(state);
965
966
}
966
967
 
967
 
static char *solve_game(game_state *state, game_state *currstate,
968
 
                        char *aux, char **error)
 
968
static char *solve_game(const game_state *state, const game_state *currstate,
 
969
                        const char *aux, char **error)
969
970
{
970
971
    int w = state->par.w, a = w*w;
971
972
    int i, ret;
998
999
    return out;
999
1000
}
1000
1001
 
1001
 
static int game_can_format_as_text_now(game_params *params)
 
1002
static int game_can_format_as_text_now(const game_params *params)
1002
1003
{
1003
1004
    return TRUE;
1004
1005
}
1005
1006
 
1006
 
static char *game_text_format(game_state *state)
 
1007
static char *game_text_format(const game_state *state)
1007
1008
{
1008
1009
    int w = state->par.w /* , a = w*w */;
1009
1010
    char *ret;
1102
1103
    int hcursor;
1103
1104
};
1104
1105
 
1105
 
static game_ui *new_ui(game_state *state)
 
1106
static game_ui *new_ui(const game_state *state)
1106
1107
{
1107
1108
    game_ui *ui = snew(game_ui);
1108
1109
 
1117
1118
    sfree(ui);
1118
1119
}
1119
1120
 
1120
 
static char *encode_ui(game_ui *ui)
 
1121
static char *encode_ui(const game_ui *ui)
1121
1122
{
1122
1123
    return NULL;
1123
1124
}
1124
1125
 
1125
 
static void decode_ui(game_ui *ui, char *encoding)
 
1126
static void decode_ui(game_ui *ui, const char *encoding)
1126
1127
{
1127
1128
}
1128
1129
 
1129
 
static void game_changed_state(game_ui *ui, game_state *oldstate,
1130
 
                               game_state *newstate)
 
1130
static void game_changed_state(game_ui *ui, const game_state *oldstate,
 
1131
                               const game_state *newstate)
1131
1132
{
1132
1133
    int w = newstate->par.w;
1133
1134
    /*
1171
1172
    int *errtmp;
1172
1173
};
1173
1174
 
1174
 
static int check_errors(game_state *state, int *errors)
 
1175
static int check_errors(const game_state *state, int *errors)
1175
1176
{
1176
1177
    int w = state->par.w /*, a = w*w */;
1177
1178
    int W = w+2, A = W*W;              /* the errors array is (w+2) square */
1255
1256
    return errs;
1256
1257
}
1257
1258
 
1258
 
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
1259
 
                            int x, int y, int button)
 
1259
static char *interpret_move(const game_state *state, game_ui *ui,
 
1260
                            const game_drawstate *ds,
 
1261
                            int x, int y, int button)
1260
1262
{
1261
1263
    int w = state->par.w;
1262
1264
    int tx, ty;
1383
1385
    return NULL;
1384
1386
}
1385
1387
 
1386
 
static game_state *execute_move(game_state *from, char *move)
 
1388
static game_state *execute_move(const game_state *from, const char *move)
1387
1389
{
1388
1390
    int w = from->par.w, a = w*w;
1389
1391
    game_state *ret;
1448
1450
 
1449
1451
#define SIZE(w) ((w) * TILESIZE + 2*BORDER)
1450
1452
 
1451
 
static void game_compute_size(game_params *params, int tilesize,
1452
 
                              int *x, int *y)
 
1453
static void game_compute_size(const game_params *params, int tilesize,
 
1454
                              int *x, int *y)
1453
1455
{
1454
1456
    /* Ick: fake up `ds->tilesize' for macro expansion purposes */
1455
1457
    struct { int tilesize; } ads, *ds = &ads;
1459
1461
}
1460
1462
 
1461
1463
static void game_set_size(drawing *dr, game_drawstate *ds,
1462
 
                          game_params *params, int tilesize)
 
1464
                          const game_params *params, int tilesize)
1463
1465
{
1464
1466
    ds->tilesize = tilesize;
1465
1467
}
1494
1496
    return ret;
1495
1497
}
1496
1498
 
1497
 
static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
 
1499
static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
1498
1500
{
1499
1501
    int w = state->par.w /*, a = w*w */;
1500
1502
    struct game_drawstate *ds = snew(struct game_drawstate);
1689
1691
    }
1690
1692
}
1691
1693
 
1692
 
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
1693
 
                        game_state *state, int dir, game_ui *ui,
1694
 
                        float animtime, float flashtime)
 
1694
static void game_redraw(drawing *dr, game_drawstate *ds,
 
1695
                        const game_state *oldstate, const game_state *state,
 
1696
                        int dir, const game_ui *ui,
 
1697
                        float animtime, float flashtime)
1695
1698
{
1696
1699
    int w = state->par.w /*, a = w*w */;
1697
1700
    int i, x, y;
1793
1796
    }
1794
1797
}
1795
1798
 
1796
 
static float game_anim_length(game_state *oldstate, game_state *newstate,
1797
 
                              int dir, game_ui *ui)
 
1799
static float game_anim_length(const game_state *oldstate,
 
1800
                              const game_state *newstate, int dir, game_ui *ui)
1798
1801
{
1799
1802
    return 0.0F;
1800
1803
}
1801
1804
 
1802
 
static float game_flash_length(game_state *oldstate, game_state *newstate,
1803
 
                               int dir, game_ui *ui)
 
1805
static float game_flash_length(const game_state *oldstate,
 
1806
                               const game_state *newstate, int dir, game_ui *ui)
1804
1807
{
1805
1808
    if (!oldstate->completed && newstate->completed &&
1806
1809
        !oldstate->cheated && !newstate->cheated)
1808
1811
    return 0.0F;
1809
1812
}
1810
1813
 
1811
 
static int game_status(game_state *state)
 
1814
static int game_status(const game_state *state)
1812
1815
{
1813
1816
    return state->completed ? +1 : 0;
1814
1817
}
1815
1818
 
1816
 
static int game_timing_state(game_state *state, game_ui *ui)
 
1819
static int game_timing_state(const game_state *state, game_ui *ui)
1817
1820
{
1818
1821
    if (state->completed)
1819
1822
        return FALSE;
1820
1823
    return TRUE;
1821
1824
}
1822
1825
 
1823
 
static void game_print_size(game_params *params, float *x, float *y)
 
1826
static void game_print_size(const game_params *params, float *x, float *y)
1824
1827
{
1825
1828
    int pw, ph;
1826
1829
 
1832
1835
    *y = ph / 100.0F;
1833
1836
}
1834
1837
 
1835
 
static void game_print(drawing *dr, game_state *state, int tilesize)
 
1838
static void game_print(drawing *dr, const game_state *state, int tilesize)
1836
1839
{
1837
1840
    int w = state->par.w;
1838
1841
    int ink = print_mono_colour(dr, 0);