Skip to content

Commit f8ffba0

Browse files
committed
fixed _set_batch, point normalize speedup
1 parent 80b79a8 commit f8ffba0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

tdl/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def draw_char(self, x, y, char, fg=Ellipsis, bg=Ellipsis):
410410
"""
411411

412412
assert _verify_colors(fg, bg)
413-
x, y = self._normalizePoint(x, y)
413+
#x, y = self._normalizePoint(x, y)
414414
#x, y = _ctypes.c_int(x), _ctypes.c_int(y)
415415
_lib.set_char(self._as_parameter_, x, y, _formatChar(char),
416416
_formatColor(fg, self._fg), _formatColor(bg, self._bg))
@@ -965,19 +965,19 @@ def _set_batch(self, batch, fg, bg, bgblend=1, nullChar=False):
965965
if bg is Ellipsis:
966966
bg = self._bg
967967

968-
if fg is not None:
968+
if fg != -1:
969969
fg = _to_tcod_color(fg)
970-
if bg is not None:
970+
if bg != -1:
971971
bg = _to_tcod_color(bg)
972972

973973

974-
if fg and not nullChar:
974+
if fg != -1 and not nullChar:
975975
# buffer values as ctypes objects
976976
self._typewriter = None # clear the typewriter as colors will be set
977977
console = self._as_parameter_
978978
#bgblend = _ctypes.c_int(bgblend)
979979

980-
if not bg:
980+
if bg == -1:
981981
bgblend = 0
982982
else:
983983
_lib.TCOD_console_set_default_background(console, bg[0])

tdl/build_libtcod.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,16 @@
402402
403403
static void set_char(TCOD_console_t console, int x, int y,
404404
int ch, int fg, int bg){
405+
// normalize x, y
406+
int width=TCOD_console_get_width(console);
407+
int height=TCOD_console_get_height(console);
408+
409+
x = x % width
410+
if(x<0){x += width;}
411+
y = y % height
412+
if(y<0){y += height;}
413+
414+
405415
TCOD_color_t color;
406416
if(ch != -1){
407417
TCOD_console_set_char(console, x, y, ch);

0 commit comments

Comments
 (0)