Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
poschengband committed May 11, 2015
2 parents d355bdc + 0301653 commit cdace5e
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 54 deletions.
2 changes: 1 addition & 1 deletion lib/file/news.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
****************************************
** PosChengband 3.4.4 **
** PosChengband 3.4.5 **
****************************************

Based on Moria: Copyright (c) 1985 Robert Alan Koeneke
Expand Down
5 changes: 1 addition & 4 deletions lib/pref/pref-gcu.prf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# This file may be included by "pref.prf", when using "main-gcu.prf".
#
# It contains macro definitions to allow the VT100 cursor keys to be
# recognized by Angband. This will also make the "escape" key take a
# few seconds to recognize, so you may want to use the "`" key instead.
#
# recognized by Angband.


### VT100 Keypad ###
Expand All @@ -20,7 +18,6 @@ P:\e[3~
A:0
P:\e[2~


# Numerical keypad keys (map to appropriate number)

A:1
Expand Down
15 changes: 14 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
From the root of the source archive:
$ sh autogen.sh
$ ./configure
% make clean
$ make clean
$ make

To install, you may need to elevate your credentials:
Expand Down Expand Up @@ -39,6 +39,19 @@

(Thanks to Nick McConnell for implementing and improving building under Linux/MAC!)

(ALT: For development, doing an install is undesirable. Try the following instead:
$ sudo apt-get install clang-3.5 llvm-3.5
$ sh autogen.sh
$ ./configure CFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address --with-no-install CC=clang-3.5
$ make clean
$ make -j4
$ cp src/poschengband .
$ ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.5 ./poschengband -g -u<Savefile> -- -n1

Note, you need to remember to copy the executable up after every build (TODO: Fix Makefile to do this!)
Also, I like to develop with the address sanitizer enabled at all times. This works best with clang as
your compiler, rather than gcc. Of course, 3.5 should be replaced with latest version of clang.).

--- Windows

Download the binary archive for Windows. Unzip it to any location that you
Expand Down
2 changes: 1 addition & 1 deletion src/cmd3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ void do_cmd_list_objects(void)
{
if (auto_pick_idx < 0) continue;
if (!(autopick_list[auto_pick_idx].action & DO_DISPLAY)) continue;
if (!(autopick_list[auto_pick_idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK))) continue;
if (!(autopick_list[auto_pick_idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK | DONT_AUTOPICK))) continue;
}
list[ct++] = i;
}
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define VER_MAJOR 3
#define VER_MINOR 4
#define VER_PATCH 4
#define VER_PATCH 5
#define VER_EXTRA 0

/*
Expand Down
162 changes: 125 additions & 37 deletions src/main-gcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,39 @@ static void Term_nuke_gcu(term *t)

#ifdef USE_GETCH

static int _getstr(char *buf, int cb)
{
int ct = 0, j;

buf[ct] = '\0';
nodelay(stdscr, TRUE);
for (;;)
{
if (ct >= cb - 1)
break;

j = getch();
if (j == ERR)
break;

buf[ct++] = (char)j;
}
buf[ct] = '\0';
nodelay(stdscr, FALSE);

return ct;
}

static void _ungetstr(const char *buf, int cb)
{
int pos;
for (pos = cb - 1; pos >= 0; pos--)
{
char ch = buf[pos];
ungetch(ch);
}
}

/*
* Process events, with optional wait
*/
Expand Down Expand Up @@ -795,6 +828,50 @@ static errr Term_xtra_gcu_event(int v)
if (i == EOF) return (1);
}

/* Issue: Currently, we map curses escape sequences via the macro processing system (see pref-gcu.prf).
* If you don't already know, this is required for things like arrow keys and the numpad and what not.
* The advantage of this approach is that users can (theoretically) edit the pref file themselves in
* the event that their terminal is sending a different escape sequence for some reason. All good, right?
* Well, except for those places in the code that *disable* macro processing! This includes all user prompts,
* the store UI (TODO) and the autopicker. Now, it's rather disconcerting if arrow keys aren't available in
* a text editor or if the user can't correct typos with backspace!
*
* The idea of translating here is from current Vanilla
* TODO */

/* Backspace */
if (i == 0x7F)
i = '\b';

if (i == 27) /* \e is not ansi c */
{
/*
char buf[255];
int cb = _getstr(buf, 255);
if (cb > 0)
{
if (strcmp(buf, "[3~") == 0)
i = '.';
else if (strcmp(buf, "[2~") == 0)
i = '0';
else if (strcmp(buf, "[4~") == 0)
i = '1';
else if (strcmp(buf, "[F") == 0)
i = '1';
else if (strcmp(buf, "[B") == 0)
i = '2';
...
else
_ungetstr(buf, cb);
}
CTK: Actually, I'm not so sure this is going to work. Arrow keys need
to be known as such by the game engine not translated to numbers. And
looking at what main-win.c and main-x11.c do to get this working is ...
uh, a bit overwhelming. So this is on hold for now ...
*/
}


/* Enqueue the keypress */
Term_keypress(i);

Expand Down Expand Up @@ -911,27 +988,55 @@ static errr Term_xtra_gcu_sound(int v)
}
#endif

static int scale_color(int i, int j, int scale)
{
return (angband_color_table[i][j] * (scale - 1) + 127) / 255;
}

static int create_color(int i, int scale)
{
int r = scale_color(i, 1, scale);
int g = scale_color(i, 2, scale);
int b = scale_color(i, 3, scale);
int rgb = 16 + scale * scale * r + scale * g + b;
/* In the case of white and black we need to use the ANSI colors */
if (r == g && g == b)
{
if (b == 0) rgb = 0;
if (b == scale) rgb = 15;
}
return rgb;
}

/*
* React to changes
*/
static errr Term_xtra_gcu_react(void)
{

#ifdef A_COLOR

int i;

/* Cannot handle color redefinition */
if (!can_fix_color) return (0);

/* Set the colors */
for (i = 0; i < 16; i++)
{
/* Set one color (note scaling) */
init_color(i, angband_color_table[i][1] * 1000 / 255,
angband_color_table[i][2] * 1000 / 255,
angband_color_table[i][3] * 1000 / 255);
}
if (COLORS == 256 || COLORS == 88)
{
/* CTK: I snagged this color handling from current Vanilla */
/* If we have more than 16 colors, find the best matches. These numbers
* correspond to xterm/rxvt's builtin color numbers--they do not
* correspond to curses' constants OR with curses' color pairs.
*
* XTerm has 216 (6*6*6) RGB colors, with each RGB setting 0-5.
* RXVT has 64 (4*4*4) RGB colors, with each RGB setting 0-3.
*
* Both also have the basic 16 ANSI colors, plus some extra grayscale
* colors which we do not use.
*/
int i;
int scale = COLORS == 256 ? 6 : 4;
for (i = 0; i < 16; i++)
{
int fg = create_color(i, scale);
init_pair(i + 1, fg, COLOR_BLACK);
colortable[i] = COLOR_PAIR(i + 1) | A_NORMAL;
}
}

#endif

Expand Down Expand Up @@ -1253,30 +1358,8 @@ errr init_gcu(int argc, char *argv[])
(COLORS >= 16) && (COLOR_PAIRS > 8));
#endif

/* Attempt to use customized colors */
if (can_fix_color)
{
/* Prepare the color pairs */
for (i = 1; i <= 63; i++)
{
/* Reset the color */
if (init_pair(i, (i - 1) % 8, (i - 1) / 8) == ERR)
{
quit("Color pair init failed");
}

/* Set up the colormap */
colortable[i - 1] = (COLOR_PAIR(i) | A_NORMAL);
colortable[i + 7] = (COLOR_PAIR(i) | A_BRIGHT);

/* XXX XXX XXX Take account of "gamma correction" */

/* Prepare the "Angband Colors" */
Term_xtra_gcu_react();
}
}
/* Attempt to use colors */
else if (can_use_color)
if (can_use_color)
{
/* Color-pair 0 is *always* WHITE on BLACK */

Expand Down Expand Up @@ -1424,6 +1507,11 @@ errr init_gcu(int argc, char *argv[])
/* Store */
term_screen = &data[0].t;

#ifdef USE_GETCH
/* Title screen (news.txt) won't draw otherwise for some reason ... */
wrefresh(stdscr);
#endif

/* Success */
return (0);
}
Expand Down
12 changes: 6 additions & 6 deletions src/race_dragon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,12 +1200,12 @@ static void _rapid_strike_spell(int cmd, variant *res)
var_set_string(res, "Attack an adjacent opponent with extra blows.");
break;
case SPELL_CAST:
p_ptr->innate_attacks[0].blows += 100;
p_ptr->innate_attacks[1].blows += 50;
p_ptr->innate_attacks[0].blows += 50;
p_ptr->innate_attacks[1].blows += 25;
var_set_bool(res, do_blow(DRAGON_RAPID_STRIKE));
/* Bug Note (Applies below as well):
* p_ptr->innate_attacks[0].blows -= 100;
* p_ptr->innate_attacks[1].blows -= 50;
* p_ptr->innate_attacks[0].blows -= 50;
* p_ptr->innate_attacks[1].blows -= 25;
* Would seem to be correct, but alas, if any code triggers a calc_bonuses() call during
* do_blow(), then the player would end up with fewer blows than normal. Alas, this *is*
* actually happening in some situations, but I haven't been able to track down the cause.
Expand All @@ -1214,8 +1214,8 @@ static void _rapid_strike_spell(int cmd, variant *res)
handle_stuff();
break;
case SPELL_ON_BROWSE:
p_ptr->innate_attacks[0].blows += 100;
p_ptr->innate_attacks[1].blows += 50;
p_ptr->innate_attacks[0].blows += 50;
p_ptr->innate_attacks[1].blows += 25;
do_cmd_knowledge_weapon();
p_ptr->update |= PU_BONUS;
handle_stuff();
Expand Down
2 changes: 1 addition & 1 deletion src/race_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ static bool _mon_save_p(monster_type *m_ptr)

/* Player may not exert their force of will out of sight! */
if (projectable(py, px, m_ptr->fy, m_ptr->fx))
pl += adj_stat_save[p_ptr->stat_ind[A_CHR]];
pl += adj_stat_save_fear[p_ptr->stat_ind[A_CHR]];

if (pl <= 1)
return TRUE;
Expand Down
4 changes: 2 additions & 2 deletions src/z-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
* Currently used whenever available, if you get a warning about
* "nodelay()" undefined, then make sure to undefine this.
*/
#if defined(SYS_V) || defined(AMIGA)
/*#if defined(SYS_V) || defined(AMIGA)*/
# define USE_GETCH
#endif
/*#endif*/

/*
* OPTION: Use the "curs_set()" call in "main-gcu.c".
Expand Down

0 comments on commit cdace5e

Please sign in to comment.