summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/undead.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/undead.c')
-rw-r--r--apps/plugins/puzzles/src/undead.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/apps/plugins/puzzles/src/undead.c b/apps/plugins/puzzles/src/undead.c
index b1f536e8d0..df0735e469 100644
--- a/apps/plugins/puzzles/src/undead.c
+++ b/apps/plugins/puzzles/src/undead.c
@@ -163,24 +163,20 @@ static config_item *game_configure(const game_params *params)
163 ret[0].name = "Width"; 163 ret[0].name = "Width";
164 ret[0].type = C_STRING; 164 ret[0].type = C_STRING;
165 sprintf(buf, "%d", params->w); 165 sprintf(buf, "%d", params->w);
166 ret[0].sval = dupstr(buf); 166 ret[0].u.string.sval = dupstr(buf);
167 ret[0].ival = 0;
168 167
169 ret[1].name = "Height"; 168 ret[1].name = "Height";
170 ret[1].type = C_STRING; 169 ret[1].type = C_STRING;
171 sprintf(buf, "%d", params->h); 170 sprintf(buf, "%d", params->h);
172 ret[1].sval = dupstr(buf); 171 ret[1].u.string.sval = dupstr(buf);
173 ret[1].ival = 0;
174 172
175 ret[2].name = "Difficulty"; 173 ret[2].name = "Difficulty";
176 ret[2].type = C_CHOICES; 174 ret[2].type = C_CHOICES;
177 ret[2].sval = DIFFCONFIG; 175 ret[2].u.choices.choicenames = DIFFCONFIG;
178 ret[2].ival = params->diff; 176 ret[2].u.choices.selected = params->diff;
179 177
180 ret[3].name = NULL; 178 ret[3].name = NULL;
181 ret[3].type = C_END; 179 ret[3].type = C_END;
182 ret[3].sval = NULL;
183 ret[3].ival = 0;
184 180
185 return ret; 181 return ret;
186} 182}
@@ -189,13 +185,13 @@ static game_params *custom_params(const config_item *cfg)
189{ 185{
190 game_params *ret = snew(game_params); 186 game_params *ret = snew(game_params);
191 187
192 ret->w = atoi(cfg[0].sval); 188 ret->w = atoi(cfg[0].u.string.sval);
193 ret->h = atoi(cfg[1].sval); 189 ret->h = atoi(cfg[1].u.string.sval);
194 ret->diff = cfg[2].ival; 190 ret->diff = cfg[2].u.choices.selected;
195 return ret; 191 return ret;
196} 192}
197 193
198static char *validate_params(const game_params *params, int full) 194static const char *validate_params(const game_params *params, int full)
199{ 195{
200 if ((params->w * params->h ) > 54) return "Grid is too big"; 196 if ((params->w * params->h ) > 54) return "Grid is too big";
201 if (params->w < 3) return "Width must be at least 3"; 197 if (params->w < 3) return "Width must be at least 3";
@@ -1440,7 +1436,7 @@ static game_state *new_game(midend *me, const game_params *params,
1440 return state; 1436 return state;
1441} 1437}
1442 1438
1443static char *validate_desc(const game_params *params, const char *desc) 1439static const char *validate_desc(const game_params *params, const char *desc)
1444{ 1440{
1445 int i; 1441 int i;
1446 int w = params->w, h = params->h; 1442 int w = params->w, h = params->h;
@@ -1493,7 +1489,7 @@ static char *validate_desc(const game_params *params, const char *desc)
1493} 1489}
1494 1490
1495static char *solve_game(const game_state *state_start, const game_state *currstate, 1491static char *solve_game(const game_state *state_start, const game_state *currstate,
1496 const char *aux, char **error) 1492 const char *aux, const char **error)
1497{ 1493{
1498 int p; 1494 int p;
1499 int *old_guess; 1495 int *old_guess;
@@ -1725,7 +1721,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1725 1721
1726 if (button == 'a' || button == 'A') { 1722 if (button == 'a' || button == 'A') {
1727 ui->ascii = !ui->ascii; 1723 ui->ascii = !ui->ascii;
1728 return ""; 1724 return UI_UPDATE;
1729 } 1725 }
1730 1726
1731 if (button == 'm' || button == 'M') { 1727 if (button == 'm' || button == 'M') {
@@ -1771,12 +1767,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1771 case CURSOR_LEFT: ui->hx -= (ui->hx > 1) ? 1 : 0; break; 1767 case CURSOR_LEFT: ui->hx -= (ui->hx > 1) ? 1 : 0; break;
1772 } 1768 }
1773 ui->hshow = ui->hcursor = 1; 1769 ui->hshow = ui->hcursor = 1;
1774 return ""; 1770 return UI_UPDATE;
1775 } 1771 }
1776 if (ui->hshow && button == CURSOR_SELECT) { 1772 if (ui->hshow && button == CURSOR_SELECT) {
1777 ui->hpencil = 1 - ui->hpencil; 1773 ui->hpencil = 1 - ui->hpencil;
1778 ui->hcursor = 1; 1774 ui->hcursor = 1;
1779 return ""; 1775 return UI_UPDATE;
1780 } 1776 }
1781 1777
1782 if (ui->hshow == 1 && ui->hpencil == 1) { 1778 if (ui->hshow == 1 && ui->hpencil == 1) {
@@ -1814,12 +1810,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1814 if (button == LEFT_BUTTON) { 1810 if (button == LEFT_BUTTON) {
1815 ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0; 1811 ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0;
1816 ui->hx = gx; ui->hy = gy; 1812 ui->hx = gx; ui->hy = gy;
1817 return ""; 1813 return UI_UPDATE;
1818 } 1814 }
1819 else if (button == RIGHT_BUTTON && g == 7) { 1815 else if (button == RIGHT_BUTTON && g == 7) {
1820 ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0; 1816 ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0;
1821 ui->hx = gx; ui->hy = gy; 1817 ui->hx = gx; ui->hy = gy;
1822 return ""; 1818 return UI_UPDATE;
1823 } 1819 }
1824 } 1820 }
1825 else if (ui->hshow == 1) { 1821 else if (ui->hshow == 1) {
@@ -1828,36 +1824,36 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1828 if (gx == ui->hx && gy == ui->hy) { 1824 if (gx == ui->hx && gy == ui->hy) {
1829 ui->hshow = 0; ui->hpencil = 0; ui->hcursor = 0; 1825 ui->hshow = 0; ui->hpencil = 0; ui->hcursor = 0;
1830 ui->hx = 0; ui->hy = 0; 1826 ui->hx = 0; ui->hy = 0;
1831 return ""; 1827 return UI_UPDATE;
1832 } 1828 }
1833 else { 1829 else {
1834 ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0; 1830 ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0;
1835 ui->hx = gx; ui->hy = gy; 1831 ui->hx = gx; ui->hy = gy;
1836 return ""; 1832 return UI_UPDATE;
1837 } 1833 }
1838 } 1834 }
1839 else { 1835 else {
1840 ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0; 1836 ui->hshow = 1; ui->hpencil = 0; ui->hcursor = 0;
1841 ui->hx = gx; ui->hy = gy; 1837 ui->hx = gx; ui->hy = gy;
1842 return ""; 1838 return UI_UPDATE;
1843 } 1839 }
1844 } 1840 }
1845 else if (button == RIGHT_BUTTON) { 1841 else if (button == RIGHT_BUTTON) {
1846 if (ui->hpencil == 0 && g == 7) { 1842 if (ui->hpencil == 0 && g == 7) {
1847 ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0; 1843 ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0;
1848 ui->hx = gx; ui->hy = gy; 1844 ui->hx = gx; ui->hy = gy;
1849 return ""; 1845 return UI_UPDATE;
1850 } 1846 }
1851 else { 1847 else {
1852 if (gx == ui->hx && gy == ui->hy) { 1848 if (gx == ui->hx && gy == ui->hy) {
1853 ui->hshow = 0; ui->hpencil = 0; ui->hcursor = 0; 1849 ui->hshow = 0; ui->hpencil = 0; ui->hcursor = 0;
1854 ui->hx = 0; ui->hy = 0; 1850 ui->hx = 0; ui->hy = 0;
1855 return ""; 1851 return UI_UPDATE;
1856 } 1852 }
1857 else if (g == 7) { 1853 else if (g == 7) {
1858 ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0; 1854 ui->hshow = 1; ui->hpencil = 1; ui->hcursor = 0;
1859 ui->hx = gx; ui->hy = gy; 1855 ui->hx = gx; ui->hy = gy;
1860 return ""; 1856 return UI_UPDATE;
1861 } 1857 }
1862 } 1858 }
1863 } 1859 }