Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0005677Dwarf FortressTechnical -- Renderingpublic2012-03-18 14:332014-12-30 14:08
calrogman 
Toady One 
normalminoralways
resolvedfixed 
MacOS X10.7.3
0.34.05 
0.40.24 
0005677: PRINT_MODE:TEXT fails on OS X; Falls back to 2D
A 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".
Set [PRINT_MODE:TEXT]. Start the game.
No tags attached.
Issue History
2012-03-18 14:33calrogmanNew Issue
2012-03-19 07:08FootkerchiefStatusnew => assigned
2012-03-19 07:08FootkerchiefAssigned To => Baughn
2012-03-19 07:08FootkerchiefNote Added: 0021597
2012-04-26 13:47calrogmanNote Added: 0022383
2012-04-26 13:48calrogmanNote Edited: 0022383bug_revision_view_page.php?bugnote_id=0022383#r8343
2012-04-26 13:49calrogmanNote Edited: 0022383bug_revision_view_page.php?bugnote_id=0022383#r8344
2012-04-26 14:39danarisIssue Monitored: danaris
2012-05-17 18:04ixtenebraeIssue Monitored: ixtenebrae
2013-01-20 04:07lethosorNote Added: 0023837
2013-01-20 04:07lethosorIssue Monitored: lethosor
2013-03-12 13:39lethosorNote View State: 0023837: private
2013-10-17 17:16lethosorNote Deleted: 0023837
2013-12-17 08:30jinpocNote Added: 0024236
2013-12-17 13:18lethosorNote Added: 0024237
2014-06-30 14:16lethosorNote Edited: 0024237bug_revision_view_page.php?bugnote_id=0024237#r9319
2014-07-11 04:05VR3Cp79dA9Note Added: 0025727
2014-07-26 21:18jinpocIssue Monitored: jinpoc
2014-11-22 07:30lethosorNote Added: 0031119
2014-11-22 07:43lethosorNote Edited: 0031119bug_revision_view_page.php?bugnote_id=0031119#r12386
2014-11-22 07:46lethosorNote Edited: 0031119bug_revision_view_page.php?bugnote_id=0031119#r12387
2014-11-22 07:46lethosorNote Edited: 0031119bug_revision_view_page.php?bugnote_id=0031119#r12388
2014-11-26 13:24Toady OneNote Added: 0031192
2014-11-26 13:49lethosorNote Added: 0031193
2014-11-26 14:02lethosorNote Edited: 0031193bug_revision_view_page.php?bugnote_id=0031193#r12426
2014-11-26 14:38lethosorNote Edited: 0031193bug_revision_view_page.php?bugnote_id=0031193#r12427
2014-11-26 14:40lethosorNote Edited: 0031193bug_revision_view_page.php?bugnote_id=0031193#r12428
2014-12-25 18:21lethosorAssigned ToBaughn => lethosor
2014-12-30 14:08Toady OneNote Added: 0031565
2014-12-30 14:08Toady OneStatusassigned => resolved
2014-12-30 14:08Toady OneFixed in Version => Next Version
2014-12-30 14:08Toady OneResolutionopen => fixed
2014-12-30 14:08Toady OneAssigned Tolethosor => Toady One

Notes
(0021597)
Footkerchief   
2012-03-19 07:08   
Reminder sent to: Baughn

Yo.
(0022383)
calrogman   
2012-04-26 13:47   
(edited on: 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.

(0024236)
jinpoc   
2013-12-17 08:30   
I'm seeing this bug on my os x 10.8.2 / df 0.34.11. Is this supposed to be fixed?
(0024237)
lethosor   
2013-12-17 13:18   
(edited on: 2014-06-30 14:16)
It is not fixed in 0.34.11.

(0025727)
VR3Cp79dA9   
2014-07-11 04:05   
Still not fixed in 0.40.02
(0031119)
lethosor   
2014-11-22 07:30   
(edited on: 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).

(0031192)
Toady One   
2014-11-26 13:24   
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.
(0031193)
lethosor   
2014-11-26 13:49   
(edited on: 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");
     
}
     


(0031565)
Toady One   
2014-12-30 14:08   
Marking this off since it seems to work, at least on 10.7+ (with one additional try on 10.6).