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

« back to all changes in this revision

Viewing changes to cube.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:
280
280
    sfree(params);
281
281
}
282
282
 
283
 
static game_params *dup_params(game_params *params)
 
283
static game_params *dup_params(const game_params *params)
284
284
{
285
285
    game_params *ret = snew(game_params);
286
286
    *ret = *params;                    /* structure copy */
304
304
    }
305
305
}
306
306
 
307
 
static char *encode_params(game_params *params, int full)
 
307
static char *encode_params(const game_params *params, int full)
308
308
{
309
309
    char data[256];
310
310
 
315
315
}
316
316
typedef void (*egc_callback)(void *, struct grid_square *);
317
317
 
318
 
static void enum_grid_squares(game_params *params, egc_callback callback, void *ctx)
 
318
static void enum_grid_squares(const game_params *params, egc_callback callback,
 
319
                              void *ctx)
319
320
{
320
321
    const struct solid *solid = solids[params->solid];
321
322
 
481
482
        return d1*d1 + d2*d2 + 4*d1*d2;
482
483
}
483
484
 
484
 
static config_item *game_configure(game_params *params)
 
485
static config_item *game_configure(const game_params *params)
485
486
{
486
487
    config_item *ret = snewn(4, config_item);
487
488
    char buf[80];
511
512
    return ret;
512
513
}
513
514
 
514
 
static game_params *custom_params(config_item *cfg)
 
515
static game_params *custom_params(const config_item *cfg)
515
516
{
516
517
    game_params *ret = snew(game_params);
517
518
 
537
538
    classes[thisclass]++;
538
539
}
539
540
 
540
 
static char *validate_params(game_params *params, int full)
 
541
static char *validate_params(const game_params *params, int full)
541
542
{
542
543
    int classes[5];
543
544
    int i;
597
598
        data->squareindex++;
598
599
}
599
600
 
600
 
static char *new_game_desc(game_params *params, random_state *rs,
 
601
static char *new_game_desc(const game_params *params, random_state *rs,
601
602
                           char **aux, int interactive)
602
603
{
603
604
    struct grid_data data;
845
846
    return ret;
846
847
}
847
848
 
848
 
static char *validate_desc(game_params *params, char *desc)
 
849
static char *validate_desc(const game_params *params, const char *desc)
849
850
{
850
851
    int area = grid_area(params->d1, params->d2, solids[params->solid]->order);
851
852
    int i, j;
873
874
    return NULL;
874
875
}
875
876
 
876
 
static game_state *new_game(midend *me, game_params *params, char *desc)
 
877
static game_state *new_game(midend *me, const game_params *params,
 
878
                            const char *desc)
877
879
{
878
880
    game_grid *grid = snew(game_grid);
879
881
    game_state *state = snew(game_state);
902
904
     * the game description.
903
905
     */
904
906
    {
905
 
        char *p = desc;
 
907
        const char *p = desc;
906
908
        int i, j, v;
907
909
 
908
910
        j = 8;
959
961
    return state;
960
962
}
961
963
 
962
 
static game_state *dup_game(game_state *state)
 
964
static game_state *dup_game(const game_state *state)
963
965
{
964
966
    game_state *ret = snew(game_state);
965
967
 
1001
1003
    sfree(state);
1002
1004
}
1003
1005
 
1004
 
static char *solve_game(game_state *state, game_state *currstate,
1005
 
                        char *aux, char **error)
 
1006
static char *solve_game(const game_state *state, const game_state *currstate,
 
1007
                        const char *aux, char **error)
1006
1008
{
1007
1009
    return NULL;
1008
1010
}
1009
1011
 
1010
 
static int game_can_format_as_text_now(game_params *params)
 
1012
static int game_can_format_as_text_now(const game_params *params)
1011
1013
{
1012
1014
    return TRUE;
1013
1015
}
1014
1016
 
1015
 
static char *game_text_format(game_state *state)
 
1017
static char *game_text_format(const game_state *state)
1016
1018
{
1017
1019
    return NULL;
1018
1020
}
1019
1021
 
1020
 
static game_ui *new_ui(game_state *state)
 
1022
static game_ui *new_ui(const game_state *state)
1021
1023
{
1022
1024
    return NULL;
1023
1025
}
1026
1028
{
1027
1029
}
1028
1030
 
1029
 
static char *encode_ui(game_ui *ui)
 
1031
static char *encode_ui(const game_ui *ui)
1030
1032
{
1031
1033
    return NULL;
1032
1034
}
1033
1035
 
1034
 
static void decode_ui(game_ui *ui, char *encoding)
 
1036
static void decode_ui(game_ui *ui, const char *encoding)
1035
1037
{
1036
1038
}
1037
1039
 
1038
 
static void game_changed_state(game_ui *ui, game_state *oldstate,
1039
 
                               game_state *newstate)
 
1040
static void game_changed_state(game_ui *ui, const game_state *oldstate,
 
1041
                               const game_state *newstate)
1040
1042
{
1041
1043
}
1042
1044
 
1048
1050
/*
1049
1051
 * Code shared between interpret_move() and execute_move().
1050
1052
 */
1051
 
static int find_move_dest(game_state *from, int direction,
 
1053
static int find_move_dest(const game_state *from, int direction,
1052
1054
                          int *skey, int *dkey)
1053
1055
{
1054
1056
    int mask, dest, i, j;
1100
1102
    return dest;
1101
1103
}
1102
1104
 
1103
 
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
1104
 
                            int x, int y, int button)
 
1105
static char *interpret_move(const game_state *state, game_ui *ui,
 
1106
                            const game_drawstate *ds,
 
1107
                            int x, int y, int button)
1105
1108
{
1106
1109
    int direction, mask, i;
1107
1110
    int skey[2], dkey[2];
1221
1224
    return NULL;                       /* should never happen */
1222
1225
}
1223
1226
 
1224
 
static game_state *execute_move(game_state *from, char *move)
 
1227
static game_state *execute_move(const game_state *from, const char *move)
1225
1228
{
1226
1229
    game_state *ret;
1227
1230
    float angle;
1462
1465
    }
1463
1466
}
1464
1467
 
1465
 
static struct bbox find_bbox(game_params *params)
 
1468
static struct bbox find_bbox(const game_params *params)
1466
1469
{
1467
1470
    struct bbox bb;
1468
1471
 
1484
1487
#define YSIZE(gs, bb, solid) \
1485
1488
    ((int)(((bb).d - (bb).u + 2*(solid)->border) * gs))
1486
1489
 
1487
 
static void game_compute_size(game_params *params, int tilesize,
1488
 
                              int *x, int *y)
 
1490
static void game_compute_size(const game_params *params, int tilesize,
 
1491
                              int *x, int *y)
1489
1492
{
1490
1493
    struct bbox bb = find_bbox(params);
1491
1494
 
1494
1497
}
1495
1498
 
1496
1499
static void game_set_size(drawing *dr, game_drawstate *ds,
1497
 
                          game_params *params, int tilesize)
 
1500
                          const game_params *params, int tilesize)
1498
1501
{
1499
1502
    struct bbox bb = find_bbox(params);
1500
1503
 
1521
1524
    return ret;
1522
1525
}
1523
1526
 
1524
 
static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
 
1527
static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
1525
1528
{
1526
1529
    struct game_drawstate *ds = snew(struct game_drawstate);
1527
1530
 
1536
1539
    sfree(ds);
1537
1540
}
1538
1541
 
1539
 
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
1540
 
                        game_state *state, int dir, game_ui *ui,
 
1542
static void game_redraw(drawing *dr, game_drawstate *ds,
 
1543
                        const game_state *oldstate, const game_state *state,
 
1544
                        int dir, const game_ui *ui,
1541
1545
                        float animtime, float flashtime)
1542
1546
{
1543
1547
    int i, j;
1544
1548
    struct bbox bb = find_bbox(&state->params);
1545
1549
    struct solid *poly;
1546
 
    int *pkey, *gkey;
 
1550
    const int *pkey, *gkey;
1547
1551
    float t[3];
1548
1552
    float angle;
1549
1553
    int square;
1552
1556
              YSIZE(GRID_SCALE, bb, state->solid), COL_BACKGROUND);
1553
1557
 
1554
1558
    if (dir < 0) {
1555
 
        game_state *t;
 
1559
        const game_state *t;
1556
1560
 
1557
1561
        /*
1558
1562
         * This is an Undo. So reverse the order of the states, and
1696
1700
    }
1697
1701
}
1698
1702
 
1699
 
static float game_anim_length(game_state *oldstate,
1700
 
                              game_state *newstate, int dir, game_ui *ui)
 
1703
static float game_anim_length(const game_state *oldstate,
 
1704
                              const game_state *newstate, int dir, game_ui *ui)
1701
1705
{
1702
1706
    return ROLLTIME;
1703
1707
}
1704
1708
 
1705
 
static float game_flash_length(game_state *oldstate,
1706
 
                               game_state *newstate, int dir, game_ui *ui)
 
1709
static float game_flash_length(const game_state *oldstate,
 
1710
                               const game_state *newstate, int dir, game_ui *ui)
1707
1711
{
1708
1712
    return 0.0F;
1709
1713
}
1710
1714
 
1711
 
static int game_status(game_state *state)
 
1715
static int game_status(const game_state *state)
1712
1716
{
1713
1717
    return state->completed ? +1 : 0;
1714
1718
}
1715
1719
 
1716
 
static int game_timing_state(game_state *state, game_ui *ui)
 
1720
static int game_timing_state(const game_state *state, game_ui *ui)
1717
1721
{
1718
1722
    return TRUE;
1719
1723
}
1720
1724
 
1721
 
static void game_print_size(game_params *params, float *x, float *y)
 
1725
static void game_print_size(const game_params *params, float *x, float *y)
1722
1726
{
1723
1727
}
1724
1728
 
1725
 
static void game_print(drawing *dr, game_state *state, int tilesize)
 
1729
static void game_print(drawing *dr, const game_state *state, int tilesize)
1726
1730
{
1727
1731
}
1728
1732