~ubuntu-branches/ubuntu/wily/sgt-puzzles/wily

« back to all changes in this revision

Viewing changes to galaxies.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:
194
194
    sfree(params);
195
195
}
196
196
 
197
 
static game_params *dup_params(game_params *params)
 
197
static game_params *dup_params(const game_params *params)
198
198
{
199
199
    game_params *ret = snew(game_params);
200
200
    *ret = *params;                    /* structure copy */
221
221
    }
222
222
}
223
223
 
224
 
static char *encode_params(game_params *params, int full)
 
224
static char *encode_params(const game_params *params, int full)
225
225
{
226
226
    char str[80];
227
227
    sprintf(str, "%dx%d", params->w, params->h);
230
230
    return dupstr(str);
231
231
}
232
232
 
233
 
static config_item *game_configure(game_params *params)
 
233
static config_item *game_configure(const game_params *params)
234
234
{
235
235
    config_item *ret;
236
236
    char buf[80];
262
262
    return ret;
263
263
}
264
264
 
265
 
static game_params *custom_params(config_item *cfg)
 
265
static game_params *custom_params(const config_item *cfg)
266
266
{
267
267
    game_params *ret = snew(game_params);
268
268
 
273
273
    return ret;
274
274
}
275
275
 
276
 
static char *validate_params(game_params *params, int full)
 
276
static char *validate_params(const game_params *params, int full)
277
277
{
278
278
    if (params->w < 3 || params->h < 3)
279
279
        return "Width and height must both be at least 3";
302
302
    space->flags &= ~F_DOT;
303
303
}
304
304
 
305
 
static void remove_assoc(game_state *state, space *tile) {
 
305
static void remove_assoc(const game_state *state, space *tile) {
306
306
    if (tile->flags & F_TILE_ASSOC) {
307
307
        SPACE(state, tile->dotx, tile->doty).nassoc--;
308
308
        tile->flags &= ~F_TILE_ASSOC;
311
311
    }
312
312
}
313
313
 
314
 
static void add_assoc(game_state *state, space *tile, space *dot) {
 
314
static void add_assoc(const game_state *state, space *tile, space *dot) {
315
315
    remove_assoc(state, tile);
316
316
 
317
317
#ifdef STANDALONE_PICTURE_GENERATOR
327
327
           tile->x, tile->y, dot->x, dot->y, dot->nassoc));*/
328
328
}
329
329
 
330
 
static struct space *sp2dot(game_state *state, int x, int y)
 
330
static struct space *sp2dot(const game_state *state, int x, int y)
331
331
{
332
332
    struct space *sp = &SPACE(state, x, y);
333
333
    if (!(sp->flags & F_TILE_ASSOC)) return NULL;
336
336
 
337
337
#define IS_VERTICAL_EDGE(x) ((x % 2) == 0)
338
338
 
339
 
static int game_can_format_as_text_now(game_params *params)
 
339
static int game_can_format_as_text_now(const game_params *params)
340
340
{
341
341
    return TRUE;
342
342
}
343
343
 
344
 
static char *game_text_format(game_state *state)
 
344
static char *game_text_format(const game_state *state)
345
345
{
346
346
    int maxlen = (state->sx+1)*state->sy, x, y;
347
347
    char *ret, *p;
398
398
    return ret;
399
399
}
400
400
 
401
 
static void dbg_state(game_state *state)
 
401
static void dbg_state(const game_state *state)
402
402
{
403
403
#ifdef DEBUGGING
404
404
    char *temp = game_text_format(state);
617
617
 
618
618
/* Returns a move string for use by 'solve', including the initial
619
619
 * 'S' if issolve is true. */
620
 
static char *diff_game(game_state *src, game_state *dest, int issolve)
 
620
static char *diff_game(const game_state *src, const game_state *dest,
 
621
                       int issolve)
621
622
{
622
623
    int movelen = 0, movesize = 256, x, y, len;
623
624
    char *move = snewn(movesize, char), buf[80], *sep = "";
819
820
    if (cleardots) game_update_dots(state);
820
821
}
821
822
 
822
 
static game_state *dup_game(game_state *state)
 
823
static game_state *dup_game(const game_state *state)
823
824
{
824
825
    game_state *ret = blank_game(state->w, state->h);
825
826
 
1230
1231
    dbg_state(state);
1231
1232
}
1232
1233
 
1233
 
static int check_complete(game_state *state, int *dsf, int *colours);
 
1234
static int check_complete(const game_state *state, int *dsf, int *colours);
1234
1235
static int solver_state(game_state *state, int maxdiff);
1235
1236
 
1236
 
static char *new_game_desc(game_params *params, random_state *rs,
 
1237
static char *new_game_desc(const game_params *params, random_state *rs,
1237
1238
                           char **aux, int interactive)
1238
1239
{
1239
1240
    game_state *state = blank_game(params->w, params->h), *copy;
1480
1481
    return (ret == -1) ? 1 : 0;
1481
1482
}
1482
1483
 
1483
 
static game_state *load_game(game_params *params, char *desc,
 
1484
static game_state *load_game(const game_params *params, const char *desc,
1484
1485
                             char **why_r)
1485
1486
{
1486
1487
    game_state *state = blank_game(params->w, params->h);
1528
1529
    return NULL;
1529
1530
}
1530
1531
 
1531
 
static char *validate_desc(game_params *params, char *desc)
 
1532
static char *validate_desc(const game_params *params, const char *desc)
1532
1533
{
1533
1534
    char *why = NULL;
1534
1535
    game_state *dummy = load_game(params, desc, &why);
1540
1541
    return why;
1541
1542
}
1542
1543
 
1543
 
static game_state *new_game(midend *me, game_params *params, char *desc)
 
1544
static game_state *new_game(midend *me, const game_params *params,
 
1545
                            const char *desc)
1544
1546
{
1545
1547
    game_state *state = load_game(params, desc, NULL);
1546
1548
    if (!state) {
2212
2214
}
2213
2215
 
2214
2216
#ifndef EDITOR
2215
 
static char *solve_game(game_state *state, game_state *currstate,
2216
 
                        char *aux, char **error)
 
2217
static char *solve_game(const game_state *state, const game_state *currstate,
 
2218
                        const char *aux, char **error)
2217
2219
{
2218
2220
    game_state *tosolve;
2219
2221
    char *ret;
2263
2265
    int cur_x, cur_y, cur_visible;
2264
2266
};
2265
2267
 
2266
 
static game_ui *new_ui(game_state *state)
 
2268
static game_ui *new_ui(const game_state *state)
2267
2269
{
2268
2270
    game_ui *ui = snew(game_ui);
2269
2271
    ui->dragging = FALSE;
2277
2279
    sfree(ui);
2278
2280
}
2279
2281
 
2280
 
static char *encode_ui(game_ui *ui)
 
2282
static char *encode_ui(const game_ui *ui)
2281
2283
{
2282
2284
    return NULL;
2283
2285
}
2284
2286
 
2285
 
static void decode_ui(game_ui *ui, char *encoding)
 
2287
static void decode_ui(game_ui *ui, const char *encoding)
2286
2288
{
2287
2289
}
2288
2290
 
2289
 
static void game_changed_state(game_ui *ui, game_state *oldstate,
2290
 
                               game_state *newstate)
 
2291
static void game_changed_state(game_ui *ui, const game_state *oldstate,
 
2292
                               const game_state *newstate)
2291
2293
{
2292
2294
}
2293
2295
 
2369
2371
#endif
2370
2372
 
2371
2373
#ifdef EDITOR
2372
 
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
2373
 
                            int x, int y, int button)
 
2374
static char *interpret_move(const game_state *state, game_ui *ui,
 
2375
                            const game_drawstate *ds,
 
2376
                            int x, int y, int button)
2374
2377
{
2375
2378
    char buf[80];
2376
2379
    int px, py;
2404
2407
    return NULL;
2405
2408
}
2406
2409
#else
2407
 
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
2408
 
                            int x, int y, int button)
 
2410
static char *interpret_move(const game_state *state, game_ui *ui,
 
2411
                            const game_drawstate *ds,
 
2412
                            int x, int y, int button)
2409
2413
{
2410
2414
    /* UI operations (play mode):
2411
2415
     *
2610
2614
}
2611
2615
#endif
2612
2616
 
2613
 
static int check_complete(game_state *state, int *dsf, int *colours)
 
2617
static int check_complete(const game_state *state, int *dsf, int *colours)
2614
2618
{
2615
2619
    int w = state->w, h = state->h;
2616
2620
    int x, y, i, ret;
2787
2791
    return ret;
2788
2792
}
2789
2793
 
2790
 
static game_state *execute_move(game_state *state, char *move)
 
2794
static game_state *execute_move(const game_state *state, const char *move)
2791
2795
{
2792
2796
    int x, y, ax, ay, n, dx, dy;
2793
2797
    game_state *ret = dup_game(state);
2907
2911
 * we may want to drag from them, for example.
2908
2912
 */
2909
2913
 
2910
 
static void game_compute_size(game_params *params, int sz,
2911
 
                              int *x, int *y)
 
2914
static void game_compute_size(const game_params *params, int sz,
 
2915
                              int *x, int *y)
2912
2916
{
2913
2917
    struct { int tilesize, w, h; } ads, *ds = &ads;
2914
2918
 
2921
2925
}
2922
2926
 
2923
2927
static void game_set_size(drawing *dr, game_drawstate *ds,
2924
 
                          game_params *params, int sz)
 
2928
                          const game_params *params, int sz)
2925
2929
{
2926
2930
    ds->tilesize = sz;
2927
2931
 
2977
2981
    /* tinge the edit background to bluey */
2978
2982
    ret[COL_BACKGROUND * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 0.8F;
2979
2983
    ret[COL_BACKGROUND * 3 + 1] = ret[COL_BACKGROUND * 3 + 0] * 0.8F;
2980
 
    ret[COL_BACKGROUND * 3 + 2] = max(ret[COL_BACKGROUND * 3 + 0] * 1.4F, 1.0F);
 
2984
    ret[COL_BACKGROUND * 3 + 2] = min(ret[COL_BACKGROUND * 3 + 0] * 1.4F, 1.0F);
2981
2985
#endif
2982
2986
 
2983
 
    ret[COL_CURSOR * 3 + 0] = max(ret[COL_BACKGROUND * 3 + 0] * 1.4F, 1.0F);
 
2987
    ret[COL_CURSOR * 3 + 0] = min(ret[COL_BACKGROUND * 3 + 0] * 1.4F, 1.0F);
2984
2988
    ret[COL_CURSOR * 3 + 1] = ret[COL_BACKGROUND * 3 + 0] * 0.8F;
2985
2989
    ret[COL_CURSOR * 3 + 2] = ret[COL_BACKGROUND * 3 + 0] * 0.8F;
2986
2990
 
2988
2992
    return ret;
2989
2993
}
2990
2994
 
2991
 
static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
 
2995
static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
2992
2996
{
2993
2997
    struct game_drawstate *ds = snew(struct game_drawstate);
2994
2998
    int i;
3145
3149
    draw_update(dr, lx, ly, TILE_SIZE, TILE_SIZE);
3146
3150
}
3147
3151
 
3148
 
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
3149
 
                        game_state *state, int dir, game_ui *ui,
3150
 
                        float animtime, float flashtime)
 
3152
static void game_redraw(drawing *dr, game_drawstate *ds,
 
3153
                        const game_state *oldstate, const game_state *state,
 
3154
                        int dir, const game_ui *ui,
 
3155
                        float animtime, float flashtime)
3151
3156
{
3152
3157
    int w = ds->w, h = ds->h;
3153
3158
    int x, y, flashing = FALSE;
3332
3337
#endif
3333
3338
}
3334
3339
 
3335
 
static float game_anim_length(game_state *oldstate, game_state *newstate,
3336
 
                              int dir, game_ui *ui)
 
3340
static float game_anim_length(const game_state *oldstate,
 
3341
                              const game_state *newstate, int dir, game_ui *ui)
3337
3342
{
3338
3343
    return 0.0F;
3339
3344
}
3340
3345
 
3341
 
static float game_flash_length(game_state *oldstate, game_state *newstate,
3342
 
                               int dir, game_ui *ui)
 
3346
static float game_flash_length(const game_state *oldstate,
 
3347
                               const game_state *newstate, int dir, game_ui *ui)
3343
3348
{
3344
3349
    if ((!oldstate->completed && newstate->completed) &&
3345
3350
        !(newstate->used_solve))
3348
3353
        return 0.0F;
3349
3354
}
3350
3355
 
3351
 
static int game_status(game_state *state)
 
3356
static int game_status(const game_state *state)
3352
3357
{
3353
3358
    return state->completed ? +1 : 0;
3354
3359
}
3355
3360
 
3356
 
static int game_timing_state(game_state *state, game_ui *ui)
 
3361
static int game_timing_state(const game_state *state, game_ui *ui)
3357
3362
{
3358
3363
    return TRUE;
3359
3364
}
3360
3365
 
3361
3366
#ifndef EDITOR
3362
 
static void game_print_size(game_params *params, float *x, float *y)
 
3367
static void game_print_size(const game_params *params, float *x, float *y)
3363
3368
{
3364
3369
   int pw, ph;
3365
3370
 
3372
3377
   *y = ph / 100.0F;
3373
3378
}
3374
3379
 
3375
 
static void game_print(drawing *dr, game_state *state, int sz)
 
3380
static void game_print(drawing *dr, const game_state *state, int sz)
3376
3381
{
3377
3382
    int w = state->w, h = state->h;
3378
3383
    int white, black, blackish;