<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40640 >

 SDL uses macro magic to rename our main() as SDL_main(). This means
that client common code library has different symbols when compiling
SDL client than otherwise. Fixing this is step toward building
multiple clients at once.

 Attached patch renames current main() in client common code as
client_main() and adds new gui specific main(), that only calls
client_main(). Now SDL can have SDL_main() while others have main().


 - ML

diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c
--- freeciv/client/civclient.c  2008-11-04 16:19:19.000000000 +0200
+++ freeciv/client/civclient.c  2009-01-07 23:05:20.000000000 +0200
@@ -19,10 +19,6 @@
 #include <windows.h>   /* LoadLibrary() */
 #endif
 
-#ifdef SDL
-#include "SDL.h"
-#endif
-
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
@@ -202,9 +198,9 @@
 }
 
 /**************************************************************************
-...
+  Entry point for common client code.
 **************************************************************************/
-int main(int argc, char *argv[])
+int client_main(int argc, char *argv[])
 {
   int i, loglevel;
   int ui_options = 0;
diff -Nurd -X.diff_ignore freeciv/client/civclient.h freeciv/client/civclient.h
--- freeciv/client/civclient.h  2008-11-04 16:19:19.000000000 +0200
+++ freeciv/client/civclient.h  2009-01-07 22:59:36.000000000 +0200
@@ -33,6 +33,8 @@
   C_S_OVER,       /* Connected with game over. */
 };
 
+int client_main(int argc, char *argv[]);
+
 void client_packet_input(void *packet, int type);
 
 void send_report_request(enum report_type type);
diff -Nurd -X.diff_ignore freeciv/client/gui-ftwl/gui_main.c 
freeciv/client/gui-ftwl/gui_main.c
--- freeciv/client/gui-ftwl/gui_main.c  2008-11-11 17:38:45.000000000 +0200
+++ freeciv/client/gui-ftwl/gui_main.c  2009-01-07 23:07:55.000000000 +0200
@@ -174,7 +174,15 @@
 }
 
 /**************************************************************************
-  The main loop for the UI.  This is called from main(), and when it
+  Entry point for whole freeciv client program.
+**************************************************************************/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**************************************************************************
+  The main loop for the UI.  This is called from client_main(), and when it
   exits the client will exit.
 **************************************************************************/
 void ui_main(int argc, char *argv[])
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/gui_main.c 
freeciv/client/gui-gtk-2.0/gui_main.c
--- freeciv/client/gui-gtk-2.0/gui_main.c       2008-11-09 00:26:56.000000000 
+0200
+++ freeciv/client/gui-gtk-2.0/gui_main.c       2009-01-07 23:07:18.000000000 
+0200
@@ -1422,7 +1422,15 @@
 }
 
 /**************************************************************************
- called from main(), is what it's named.
+  Entry point for whole freeciv client program.
+**************************************************************************/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**************************************************************************
+  Called from client_main(), is what it's named.
 **************************************************************************/
 void ui_main(int argc, char **argv)
 {
diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/gui_main.c 
freeciv/client/gui-sdl/gui_main.c
--- freeciv/client/gui-sdl/gui_main.c   2008-11-11 17:38:45.000000000 +0200
+++ freeciv/client/gui-sdl/gui_main.c   2009-01-07 23:07:05.000000000 +0200
@@ -884,6 +884,16 @@
 }
 
 /**************************************************************************
+  Entry point for freeciv client program. SDL has macro magic to turn
+  this in to function named SDL_main() and it provides actual main()
+  itself.
+**************************************************************************/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**************************************************************************
   The main loop for the UI.  This is called from main(), and when it
   exits the client will exit.
 **************************************************************************/
diff -Nurd -X.diff_ignore freeciv/client/gui-stub/gui_main.c 
freeciv/client/gui-stub/gui_main.c
--- freeciv/client/gui-stub/gui_main.c  2008-11-11 17:38:45.000000000 +0200
+++ freeciv/client/gui-stub/gui_main.c  2009-01-07 23:07:31.000000000 +0200
@@ -59,6 +59,14 @@
 }
 
 /**************************************************************************
+  Entry point for whole freeciv client program.
+**************************************************************************/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**************************************************************************
   The main loop for the UI.  This is called from main(), and when it
   exits the client will exit.
 **************************************************************************/
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/gui_main.c 
freeciv/client/gui-win32/gui_main.c
--- freeciv/client/gui-win32/gui_main.c 2008-11-11 17:38:45.000000000 +0200
+++ freeciv/client/gui-win32/gui_main.c 2009-01-07 23:07:38.000000000 +0200
@@ -714,7 +714,15 @@
 extern void anim_cursor(float time);
 
 /**************************************************************************
+  Entry point for whole freeciv client program.
+**************************************************************************/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
 
+/**************************************************************************
+  Entry point for GUI specific portion. Called from client_main()
 **************************************************************************/
 void
 ui_main(int argc, char *argv[])
diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/gui_main.c 
freeciv/client/gui-xaw/gui_main.c
--- freeciv/client/gui-xaw/gui_main.c   2008-11-11 17:38:45.000000000 +0200
+++ freeciv/client/gui-xaw/gui_main.c   2009-01-07 23:07:48.000000000 +0200
@@ -290,7 +290,15 @@
 }
 
 /**************************************************************************
-...
+  Entry point for whole freeciv client program.
+**************************************************************************/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**************************************************************************
+  Entry point for GUI specific portion. Called from client_main()
 **************************************************************************/
 void ui_main(int argc, char *argv[])
 {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to