View Issue Details

IDProjectCategoryView StatusLast Update
0005677Dwarf FortressTechnical -- Renderingpublic2014-12-30 14:08
Reportercalrogman Assigned ToToady One  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformMacOSOS XOS Version10.7.3
Product Version0.34.05 
Fixed in Version0.40.24 
Summary0005677: PRINT_MODE:TEXT fails on OS X; Falls back to 2D
DescriptionA comment in data/init/init.txt reads:

  Linux/OS X users may also use PRINT_MODE:TEXT for primitive ncurses output.

However, on OS X, setting PRINT_MODE to TEXT and starting the game causes a message box to appear, reading "Text mode not supported on your platform, using 2D".
Steps To ReproduceSet [PRINT_MODE:TEXT]. Start the game.
TagsNo tags attached.

Activities

user6

2012-03-19 07:08

  ~0021597

Reminder sent to: Baughn

Yo.

calrogman

2012-04-26 13:47

reporter   ~0022383

Last edited: 2012-04-26 13:49

Don't mean to pester but, any updates on this?

It looks to me like a very simple problem with the build chain (a missing DEFINE when compiling for OS X).

Lines 143-152 of g_src/init.cpp are seemingly relevant.

jinpoc

2013-12-17 08:30

reporter   ~0024236

I'm seeing this bug on my os x 10.8.2 / df 0.34.11. Is this supposed to be fixed?

lethosor

2013-12-17 13:18

manager   ~0024237

Last edited: 2014-06-30 14:16

It is not fixed in 0.34.11.

VR3Cp79dA9

2014-07-11 04:05

reporter   ~0025727

Still not fixed in 0.40.02

lethosor

2014-11-22 07:30

manager   ~0031119

Last edited: 2014-11-22 07:46

This is an (untested) patch that may solve this problem:

diff -u -x '*~' g_src/curses.h g_src_patched/curses.h
--- g_src/curses.h	2014-11-22 10:26:32.000000000 -0500
+++ g_src_patched/curses.h	2014-11-22 10:28:10.000000000 -0500
@@ -3,26 +3,26 @@
 
 extern "C" {
 #include "GL/glew.h"
-#ifndef __APPLE__
-#ifdef unix
+#if defined(__unix__) || defined(__APPLE__)
+#ifdef __APPLE__
+# include <curses.h>
+#else
 # include <ncursesw/curses.h>
+#endif
 # undef COLOR_BLUE
 # undef COLOR_CYAN
 # undef COLOR_RED
 # undef COLOR_YELLOW
 # include <dlfcn.h>
 #endif
-#endif
 }
 
-#ifndef __APPLE__
-#ifdef unix
+#if defined(__unix__) || defined(__APPLE__)
 extern "C" {
   void init_curses();
   extern WINDOW **stdscr_p;
 };
 #endif
-#endif
 
 
 #endif
diff -u -x '*~' g_src/renderer_curses.cpp g_src_patched/renderer_curses.cpp
--- g_src/renderer_curses.cpp	2014-11-20 16:39:35.000000000 -0500
+++ g_src_patched/renderer_curses.cpp	2014-11-22 10:30:02.000000000 -0500
@@ -298,6 +298,8 @@
       if (handle) goto opened;
       handle = dlopen("libncursesw.so", RTLD_LAZY);
       if (handle) goto opened;
+      handle = dlopen("libncurses.dylib", RTLD_LAZY);
+      if (handle) goto opened;
       puts("Didn't find any flavor of libncursesw, attempting libncurses");
       sleep(5);
       handle = dlopen("libncurses.so.5", RTLD_LAZY);


Usage:
cd g_src && patch -p1 < [patch file]


(Note that this isn't actually possible to test on OS X, since libgraphics is statically linked).

Toady One

2014-11-26 13:24

administrator   ~0031192

I'm getting 'mvwaddwstr' was not declared when it tries to compile renderer_curses.cpp. I don't appear to have a ncursesw directory with includes to try. Just a curses.h and a ncurses.h in usr/include, and neither of those have what is needed.

lethosor

2014-11-26 13:49

manager   ~0031193

Last edited: 2014-11-26 14:40

What's the value of NCURSES_VERSION?
Edit: Try defining _XOPEN_SOURCE_EXTENDED before including curses.h
Edit 2: You may have to update ncurses if that doesn't work; I'm not sure how best to do this without installing Homebrew or Macports (which should be manageable if Xcode is already installed).
This patch might allow it to compile on 10.6 and work on platforms where addwstr is available:

diff -u -x '*~' g_src/renderer_curses.cpp g_src_patched/renderer_curses.cpp
--- g_src/renderer_curses.cpp	2014-11-22 10:40:25.000000000 -0500
+++ g_src_patched/renderer_curses.cpp	2014-11-26 17:39:58.000000000 -0500
@@ -221,6 +221,7 @@
   static int (*_start_color)(void);
   static int (*_init_pair)(short p, short fg, short bg);
   static int (*_getmouse)(MEVENT *m);
+  static int (*_waddwstr)(WINDOW *w, const wchar_t *s);
   static int (*_waddnwstr)(WINDOW *w, const wchar_t *s, int i);
 
   static void *dlsym_orexit(const char *symbol, bool actually_exit = true) {
@@ -284,6 +285,9 @@
   int getmouse(MEVENT *m) {
     return _getmouse(m);
   }
+  int waddwstr(WINDOW *w, const wchar_t *s) {
+    return _waddwstr(w, s);
+  }
   int waddnwstr(WINDOW *w, const wchar_t *s, int n) {
     return _waddnwstr(w, s, n);
   }
@@ -332,6 +336,7 @@
       _start_color = (int (*)(void))dlsym_orexit("start_color");
       _init_pair = (int (*)(short p, short fg, short bg))dlsym_orexit("init_pair");
       _getmouse = (int (*)(MEVENT *m))dlsym_orexit("getmouse");
+      _waddwstr = (int (*)(WINDOW *w, const wchar_t *s))dlsym_orexit("waddwstr");
       _waddnwstr = (int (*)(WINDOW *w, const wchar_t *s, int i))dlsym_orexit("waddnwstr");
     }
     


Toady One

2014-12-30 14:08

administrator   ~0031565

Marking this off since it seems to work, at least on 10.7+ (with one additional try on 10.6).

Issue History

Date Modified Username Field Change
2012-03-18 14:33 calrogman New Issue
2012-03-19 07:08 user6 Status new => assigned
2012-03-19 07:08 user6 Assigned To => Baughn
2012-03-19 07:08 user6 Note Added: 0021597
2012-04-26 13:47 calrogman Note Added: 0022383
2012-04-26 13:48 calrogman Note Edited: 0022383
2012-04-26 13:49 calrogman Note Edited: 0022383
2013-12-17 08:30 jinpoc Note Added: 0024236
2013-12-17 13:18 lethosor Note Added: 0024237
2014-06-30 14:16 lethosor Note Edited: 0024237
2014-07-11 04:05 VR3Cp79dA9 Note Added: 0025727
2014-11-22 07:30 lethosor Note Added: 0031119
2014-11-22 07:43 lethosor Note Edited: 0031119
2014-11-22 07:46 lethosor Note Edited: 0031119
2014-11-22 07:46 lethosor Note Edited: 0031119
2014-11-26 13:24 Toady One Note Added: 0031192
2014-11-26 13:49 lethosor Note Added: 0031193
2014-11-26 14:02 lethosor Note Edited: 0031193
2014-11-26 14:38 lethosor Note Edited: 0031193
2014-11-26 14:40 lethosor Note Edited: 0031193
2014-12-25 18:21 lethosor Assigned To Baughn => lethosor
2014-12-30 14:08 Toady One Note Added: 0031565
2014-12-30 14:08 Toady One Status assigned => resolved
2014-12-30 14:08 Toady One Fixed in Version => Next Version
2014-12-30 14:08 Toady One Resolution open => fixed
2014-12-30 14:08 Toady One Assigned To lethosor => Toady One