diff --git a/include/config.h b/include/config.h index 7083a09bf..492ff2bfc 100644 --- a/include/config.h +++ b/include/config.h @@ -96,6 +96,7 @@ #endif #ifdef QT_GRAPHICS +#include "../win/Qt/qt_redef.h" #ifndef DEFAULT_WC_TILED_MAP #define DEFAULT_WC_TILED_MAP /* Default to tiles if users doesn't say \ wc_ascii_map */ diff --git a/win/Qt/qt_bind.cpp b/win/Qt/qt_bind.cpp index cb875f115..ca34f5135 100644 --- a/win/Qt/qt_bind.cpp +++ b/win/Qt/qt_bind.cpp @@ -17,6 +17,7 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #include #if QT_VERSION >= 0x050000 @@ -25,6 +26,7 @@ extern "C" { #else #include #endif +#include "qt_redef.h" #include "qt_bind.h" #include "qt_click.h" #ifdef TIMED_DELAY diff --git a/win/Qt/qt_click.cpp b/win/Qt/qt_click.cpp index 6cee16258..30656264e 100644 --- a/win/Qt/qt_click.cpp +++ b/win/Qt/qt_click.cpp @@ -15,7 +15,9 @@ #undef min #undef max +#include "qt_undef.h" #include +#include "qt_redef.h" #include "qt_click.h" namespace nethack_qt_ { diff --git a/win/Qt/qt_delay.cpp b/win/Qt/qt_delay.cpp index 1728b3702..592bc23cb 100644 --- a/win/Qt/qt_delay.cpp +++ b/win/Qt/qt_delay.cpp @@ -15,7 +15,9 @@ #undef min #undef max +#include "qt_undef.h" #include +#include "qt_redef.h" #include "qt_delay.h" namespace nethack_qt_ { diff --git a/win/Qt/qt_glyph.cpp b/win/Qt/qt_glyph.cpp index a3e4f24ef..88349b9ee 100644 --- a/win/Qt/qt_glyph.cpp +++ b/win/Qt/qt_glyph.cpp @@ -18,10 +18,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_glyph.h" #include "qt_set.h" #include "qt_str.h" diff --git a/win/Qt/qt_icon.cpp b/win/Qt/qt_icon.cpp index 160fc7e10..bcbc529ae 100644 --- a/win/Qt/qt_icon.cpp +++ b/win/Qt/qt_icon.cpp @@ -15,10 +15,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_icon.h" namespace nethack_qt_ { diff --git a/win/Qt/qt_inv.cpp b/win/Qt/qt_inv.cpp index be31d536e..3bb6cb55b 100644 --- a/win/Qt/qt_inv.cpp +++ b/win/Qt/qt_inv.cpp @@ -18,10 +18,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_inv.h" #include "qt_glyph.h" #include "qt_set.h" diff --git a/win/Qt/qt_key.cpp b/win/Qt/qt_key.cpp index 2a43f7c85..aa48741c1 100644 --- a/win/Qt/qt_key.cpp +++ b/win/Qt/qt_key.cpp @@ -15,7 +15,9 @@ #undef min #undef max +#include "qt_undef.h" #include +#include "qt_redef.h" #include "qt_key.h" namespace nethack_qt_ { @@ -28,9 +30,10 @@ NetHackQtKeyBuffer::NetHackQtKeyBuffer() : bool NetHackQtKeyBuffer::Empty() const { return in==out; } bool NetHackQtKeyBuffer::Full() const { return (in+1)%maxkey==out; } -void NetHackQtKeyBuffer::Put(int k, int a, int state) +void NetHackQtKeyBuffer::Put(int k, int a, int kbstate) { if ( Full() ) return; // Safety + nhUse(kbstate); key[in]=k; ascii[in]=a; in=(in+1)%maxkey; diff --git a/win/Qt/qt_line.cpp b/win/Qt/qt_line.cpp index 6374bea3f..790d72a42 100644 --- a/win/Qt/qt_line.cpp +++ b/win/Qt/qt_line.cpp @@ -15,10 +15,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_line.h" namespace nethack_qt_ { diff --git a/win/Qt/qt_main.cpp b/win/Qt/qt_main.cpp index b27b1067c..b86f85f31 100644 --- a/win/Qt/qt_main.cpp +++ b/win/Qt/qt_main.cpp @@ -17,10 +17,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_main.h" #include "qt_main.moc" #include "qt_bind.h" diff --git a/win/Qt/qt_map.cpp b/win/Qt/qt_map.cpp index 74d30b3c8..d32ebfbf0 100644 --- a/win/Qt/qt_map.cpp +++ b/win/Qt/qt_map.cpp @@ -17,10 +17,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_map.h" #include "qt_map.moc" #include "qt_click.h" diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index b959ad5d0..76b1aa2b5 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -17,10 +17,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_menu.h" #include "qt_menu.moc" #include "qt_glyph.h" diff --git a/win/Qt/qt_msg.cpp b/win/Qt/qt_msg.cpp index 516e992df..9cf789d96 100644 --- a/win/Qt/qt_msg.cpp +++ b/win/Qt/qt_msg.cpp @@ -17,10 +17,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_msg.h" #include "qt_msg.moc" #include "qt_map.h" diff --git a/win/Qt/qt_plsel.cpp b/win/Qt/qt_plsel.cpp index c77203bec..8598bbd81 100644 --- a/win/Qt/qt_plsel.cpp +++ b/win/Qt/qt_plsel.cpp @@ -17,10 +17,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_plsel.h" #include "qt_plsel.moc" #include "qt_bind.h" diff --git a/win/Qt/qt_redef.h b/win/Qt/qt_redef.h new file mode 100644 index 000000000..5e6c15e4a --- /dev/null +++ b/win/Qt/qt_redef.h @@ -0,0 +1,19 @@ +#if defined(QT_GRAPHICS) +#if defined(MACOSX) + +/* + * The following conflict with Qt header files so after + * undefing them in qt_undef.h, we redefine them back to + * the non-conflicting names again in here, presumably + * right after the Qt header files with the conflicts have + * been included. + */ + +#define u NETHACK_u +#define flags NETHACK_flags +#define g NETHACK_g +#define cg NETHACK_cg + +#endif /* MACOSX */ +#endif /* QT_GRAPHICS */ + diff --git a/win/Qt/qt_rip.cpp b/win/Qt/qt_rip.cpp index cbe795f85..c95089378 100644 --- a/win/Qt/qt_rip.cpp +++ b/win/Qt/qt_rip.cpp @@ -15,10 +15,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_rip.h" #include "qt_bind.h" #include "qt_str.h" diff --git a/win/Qt/qt_set.cpp b/win/Qt/qt_set.cpp index 2ac70fd9d..8748f5159 100644 --- a/win/Qt/qt_set.cpp +++ b/win/Qt/qt_set.cpp @@ -15,10 +15,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_set.h" #include "qt_set.moc" #include "qt_glyph.h" diff --git a/win/Qt/qt_stat.cpp b/win/Qt/qt_stat.cpp index 5e6918f00..c6f4ab737 100644 --- a/win/Qt/qt_stat.cpp +++ b/win/Qt/qt_stat.cpp @@ -17,10 +17,12 @@ extern "C" { #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_stat.h" #include "qt_stat.moc" #include "qt_set.h" diff --git a/win/Qt/qt_streq.cpp b/win/Qt/qt_streq.cpp index c489e5800..419aba8cc 100644 --- a/win/Qt/qt_streq.cpp +++ b/win/Qt/qt_streq.cpp @@ -15,10 +15,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_streq.h" #include "qt_str.h" diff --git a/win/Qt/qt_svsel.cpp b/win/Qt/qt_svsel.cpp index 6950afd79..2b429cb98 100644 --- a/win/Qt/qt_svsel.cpp +++ b/win/Qt/qt_svsel.cpp @@ -15,10 +15,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_svsel.h" #include "qt_bind.h" #include "qt_str.h" diff --git a/win/Qt/qt_undef.h b/win/Qt/qt_undef.h new file mode 100644 index 000000000..9b98e7737 --- /dev/null +++ b/win/Qt/qt_undef.h @@ -0,0 +1,17 @@ +#if defined(QT_GRAPHICS) +#if defined(MACOSX) + +/* + * The following conflict with Qt header files so we + * undef them in here, then redef them using qt_redef.h + * after the Qt includes. + */ + +#undef u +#undef flags +#undef g +#undef cg + +#endif /* MACOSX */ +#endif /* QT_GRAPHICS */ + diff --git a/win/Qt/qt_win.cpp b/win/Qt/qt_win.cpp index 8c4ecac04..dbd756bf3 100644 --- a/win/Qt/qt_win.cpp +++ b/win/Qt/qt_win.cpp @@ -57,10 +57,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_win.h" #include "qt_bind.h" #include "qt_click.h" diff --git a/win/Qt/qt_xcmd.cpp b/win/Qt/qt_xcmd.cpp index a994d4eae..4aeffe98e 100644 --- a/win/Qt/qt_xcmd.cpp +++ b/win/Qt/qt_xcmd.cpp @@ -16,10 +16,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_xcmd.h" #include "qt_xcmd.moc" #include "qt_bind.h" diff --git a/win/Qt/qt_yndlg.cpp b/win/Qt/qt_yndlg.cpp index 8d1caf400..55d31e67b 100644 --- a/win/Qt/qt_yndlg.cpp +++ b/win/Qt/qt_yndlg.cpp @@ -15,10 +15,12 @@ #undef min #undef max +#include "qt_undef.h" #include #if QT_VERSION >= 0x050000 #include #endif +#include "qt_redef.h" #include "qt_yndlg.h" #include "qt_yndlg.moc" #include "qt_str.h"