Ver código fonte

Prepare for the code modernisation.
- Apply reformat on all files (there are still some work to do there)
- Create all needed CMakeLists
- Added needed submodules for the remastered version (using glfw and imgui instead of GTK)
- Removed all CVS keyword founds
- Removed all remnants of the autotools.

The code will not build for now, but that's not the goal, lots are going to be removed anyway.

Godzil 2 anos atrás
pai
commit
c4c0cc34a6
100 arquivos alterados com 6745 adições e 6572 exclusões
  1. 9 0
      .gitmodules
  2. 9 5
      CMakeLists.txt
  3. 11 0
      data/CMakeLists.txt
  4. 0 10
      data/Makefile.am
  5. 0 311
      data/Makefile.in
  6. 1 1
      data/map/2players.map
  7. 1 1
      data/map/4players.map
  8. 1 1
      data/map/Makefile.am
  9. 1 1
      data/map/Makefile.in
  10. 1 1
      data/map/center.map
  11. 1 1
      data/map/pulse-4.map
  12. 1 1
      data/map/small.map
  13. 12 0
      doc/CMakeLists.txt
  14. 0 2
      doc/ChangeLog
  15. 0 22
      doc/Makefile.am
  16. 0 279
      doc/Makefile.in
  17. 0 2
      doc/TODO
  18. 1 0
      external/cjson
  19. 0 0
      external/cmake/CJSON.cmake
  20. 0 0
      external/cmake/FindCJSON.cmake
  21. 0 0
      external/cmake/GetGitRevisionDescription.cmake
  22. 0 0
      external/cmake/GetGitRevisionDescription.cmake.in
  23. 1 0
      external/glfw
  24. 1 0
      external/imgui
  25. 18 0
      gclient/CMakeLists.txt
  26. 0 13
      gclient/Makefile.am
  27. 50 50
      gclient/gamearea.c
  28. 577 465
      gclient/gen_bigmap.c
  29. 497 415
      gclient/gen_bigmap2.c
  30. 3 5
      gclient/gen_minimap.c
  31. 27 27
      gclient/gtk.c
  32. 106 80
      gclient/include/client.h
  33. 17 2
      gclient/include/client_gtk.h
  34. 90 86
      gclient/init.c
  35. 139 129
      gclient/load_map.c
  36. 7 9
      gclient/main.c
  37. 60 62
      gclient/mainbox.c
  38. 90 72
      gclient/map.c
  39. 94 87
      gclient/menubar.c
  40. 62 56
      gclient/minimap.c
  41. 123 107
      gclient/network.c
  42. 118 96
      gclient/pixbuf.c
  43. 77 74
      gclient/players.c
  44. 327 278
      gclient/stats.c
  45. 9 11
      gclient/statusbar.c
  46. 133 123
      gclient/toolbar.c
  47. 13 0
      gtkutil/CMakeLists.txt
  48. 0 7
      gtkutil/Makefile.am
  49. 15 13
      gtkutil/callbacks.c
  50. 102 77
      gtkutil/clist.c
  51. 112 106
      gtkutil/create.c
  52. 32 32
      gtkutil/filesel.c
  53. 1 1
      include/client/c++/prolo.hh
  54. 1 1
      include/client/c/prolo.h
  55. 1 1
      include/client/cpp/prolo.hh
  56. 0 2
      include/general.h
  57. 25 9
      include/gtkutil.h
  58. 38 16
      include/pulsarnet.h
  59. 18 0
      meta-client/CMakeLists.txt
  60. 0 14
      meta-client/Makefile.am
  61. 89 83
      meta-client/bitmaps.c
  62. 38 35
      meta-client/champions.c
  63. 187 185
      meta-client/gtk_main.c
  64. 29 14
      meta-client/include/mclient.h
  65. 38 30
      meta-client/include/mysql.h
  66. 19 17
      meta-client/include/tournois.h
  67. 100 87
      meta-client/init.c
  68. 4 6
      meta-client/main.c
  69. 63 56
      meta-client/maps.c
  70. 42 42
      meta-client/matchs.c
  71. 114 107
      meta-client/menubar.c
  72. 64 56
      meta-client/mysql.c
  73. 425 384
      meta-client/mysql_list.c
  74. 557 495
      meta-client/run_match.c
  75. 331 282
      meta-client/run_tournois.c
  76. 191 181
      meta-client/tournois.c
  77. 14 0
      pulsarnet/CMakeLists.txt
  78. 0 8
      pulsarnet/Makefile.am
  79. 54 41
      pulsarnet/check.c
  80. 26 20
      pulsarnet/error.c
  81. 19 17
      pulsarnet/misc.c
  82. 2 3
      pulsarnet/net_private.h
  83. 61 44
      pulsarnet/open.c
  84. 85 65
      pulsarnet/read.c
  85. 63 41
      pulsarnet/write.c
  86. 1 1
      server/CMakeLists.txt
  87. 467 467
      server/client.c
  88. 42 42
      server/conf.c
  89. 372 372
      server/exec.c
  90. 153 155
      server/game.c
  91. 0 2
      server/include/action.h
  92. 2 2
      server/include/client.h
  93. 31 33
      server/include/conf.h
  94. 8 10
      server/include/erreur.h
  95. 13 13
      server/include/exec.h
  96. 1 2
      server/include/game.h
  97. 4 2
      server/include/ipc.h
  98. 1 3
      server/include/message.h
  99. 1 3
      server/include/network.h
  100. 1 2
      server/include/objects.h

+ 9 - 0
.gitmodules

@@ -0,0 +1,9 @@
+[submodule "external/imgui"]
+	path = external/imgui
+	url = https://github.com/ocornut/imgui.git
+[submodule "external/glfw"]
+	path = external/glfw
+	url = https://github.com/glfw/glfw.git
+[submodule "external/cjson"]
+	path = external/cjson
+	url = https://github.com/DaveGamble/cJSON.git

+ 9 - 5
CMakeLists.txt

@@ -1,9 +1,9 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.10)
 
 project(ThePulsars)
 
 # External cmake modules
-set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/cmake ${CMAKE_MODULE_PATH})
 
 # Options for the project
 option(BUILD_SERVER "Build server" ON)
@@ -21,7 +21,7 @@ include_directories(include)
 include(GetGitRevisionDescription)
 git_describe(VERSION --tags --dirty=-dirty)
 
-#parse the version information into pieces.
+# Parse the version information into pieces.
 string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
 string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
 string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_MICRO "${VERSION}")
@@ -32,13 +32,17 @@ add_compile_options(-DV_MINOR=${VERSION_MINOR})
 add_compile_options(-DV_MICRO=${VERSION_MICRO})
 add_compile_options(-DV_SHA=${VERSION_SHA1})
 
-
-#add_subdirectory(pulsarnet)
+add_subdirectory(doc)
+add_subdirectory(data)
 
 if (BUILD_SERVER)
     add_subdirectory(server)
 endif()
 
+if (BUILD_GCLIENT OR BUILD_METACLIENT OR BUILD_SERVER)
+    add_subdirectory(pulsarnet)
+endif()
+
 if (BUILD_GCLIENT OR BUILD_METACLIENT)
     add_subdirectory(gtkutil)
 endif()

+ 11 - 0
data/CMakeLists.txt

@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(PulsarAssets)
+
+file(GLOB IMAGES_FILES *.xpm *.gif)
+
+install(FILES ${IMAGES_FILES}
+        DESTINATION assets)
+
+install(DIRECTORY map
+        DESTINATION assets)

+ 0 - 10
data/Makefile.am

@@ -1,10 +0,0 @@
-# $Id: Makefile.am,v 1.3 2001/05/06 08:37:02 kilobug Exp $
-
-SUBDIRS		= map
-data_DATA	= akx_0_mask.xpm  akx_0.xpm  akx_mask.xpm  akx.xpm \
-		  r4d2_0_mask.xpm  r4d2_0.xpm  r4d2_mask.xpm  r4d2.xpm \
-		  ffwd.xpm  pause.xpm  play.xpm  step.xpm \
-		  logo_small.xpm  logo.xpm \
-		  sand.gif
-
-EXTRA_DIST	= $(data_DATA)

+ 0 - 311
data/Makefile.in

@@ -1,311 +0,0 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-# $Id: Makefile.am,v 1.3 2001/05/06 08:37:02 kilobug Exp $
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-CC = @CC@
-CFLAGS = @CFLAGS@
-GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
-GDK_PIXBUF_CONFIG = @GDK_PIXBUF_CONFIG@
-GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
-GLIB_CFLAGS = @GLIB_CFLAGS@
-GLIB_CONFIG = @GLIB_CONFIG@
-GLIB_LIBS = @GLIB_LIBS@
-GTK_CFLAGS = @GTK_CFLAGS@
-GTK_CONFIG = @GTK_CONFIG@
-GTK_LIBS = @GTK_LIBS@
-LDFLAGS = @LDFLAGS@
-MAKEINFO = @MAKEINFO@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-VERSION = @VERSION@
-
-SUBDIRS = map
-data_DATA = akx_0_mask.xpm  akx_0.xpm  akx_mask.xpm  akx.xpm 		  r4d2_0_mask.xpm  r4d2_0.xpm  r4d2_mask.xpm  r4d2.xpm 		  ffwd.xpm  pause.xpm  play.xpm  step.xpm 		  logo_small.xpm  logo.xpm 		  sand.gif
-
-
-EXTRA_DIST = $(data_DATA)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../config.h
-CONFIG_CLEAN_FILES = 
-DATA =  $(data_DATA)
-
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps data/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-install-dataDATA: $(data_DATA)
-	@$(NORMAL_INSTALL)
-	$(mkinstalldirs) $(DESTDIR)$(datadir)
-	@list='$(data_DATA)'; for p in $$list; do \
-	  if test -f $(srcdir)/$$p; then \
-	    echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p"; \
-	    $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p; \
-	  else if test -f $$p; then \
-	    echo " $(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p"; \
-	    $(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p; \
-	  fi; fi; \
-	done
-
-uninstall-dataDATA:
-	@$(NORMAL_UNINSTALL)
-	list='$(data_DATA)'; for p in $$list; do \
-	  rm -f $(DESTDIR)$(datadir)/$$p; \
-	done
-
-# This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-#     (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-
-@SET_MAKE@
-
-all-recursive install-data-recursive install-exec-recursive \
-installdirs-recursive install-recursive uninstall-recursive  \
-check-recursive installcheck-recursive info-recursive dvi-recursive:
-	@set fnord $(MAKEFLAGS); amf=$$2; \
-	dot_seen=no; \
-	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    dot_seen=yes; \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
-	done; \
-	if test "$$dot_seen" = "no"; then \
-	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
-	fi; test -z "$$fail"
-
-mostlyclean-recursive clean-recursive distclean-recursive \
-maintainer-clean-recursive:
-	@set fnord $(MAKEFLAGS); amf=$$2; \
-	dot_seen=no; \
-	rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
-	  rev="$$subdir $$rev"; \
-	  test "$$subdir" = "." && dot_seen=yes; \
-	done; \
-	test "$$dot_seen" = "no" && rev=". $$rev"; \
-	target=`echo $@ | sed s/-recursive//`; \
-	for subdir in $$rev; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
-	done && test -z "$$fail"
-tags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
-	done
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-   if test "$$subdir" = .; then :; else \
-	    test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
-   fi; \
-	done; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
-
-mostlyclean-tags:
-
-clean-tags:
-
-distclean-tags:
-	-rm -f TAGS ID
-
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = data
-
-distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
-	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
-	  fi; \
-	done
-	for subdir in $(SUBDIRS); do \
-	  if test "$$subdir" = .; then :; else \
-	    test -d $(distdir)/$$subdir \
-	    || mkdir $(distdir)/$$subdir \
-	    || exit 1; \
-	    chmod 777 $(distdir)/$$subdir; \
-	    (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
-	      || exit 1; \
-	  fi; \
-	done
-info-am:
-info: info-recursive
-dvi-am:
-dvi: dvi-recursive
-check-am: all-am
-check: check-recursive
-installcheck-am:
-installcheck: installcheck-recursive
-install-exec-am:
-install-exec: install-exec-recursive
-
-install-data-am: install-dataDATA
-install-data: install-data-recursive
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-recursive
-uninstall-am: uninstall-dataDATA
-uninstall: uninstall-recursive
-all-am: Makefile $(DATA)
-all-redirect: all-recursive
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs: installdirs-recursive
-installdirs-am:
-	$(mkinstalldirs)  $(DESTDIR)$(datadir)
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-recursive
-
-clean-am:  clean-tags clean-generic mostlyclean-am
-
-clean: clean-recursive
-
-distclean-am:  distclean-tags distclean-generic clean-am
-
-distclean: distclean-recursive
-
-maintainer-clean-am:  maintainer-clean-tags maintainer-clean-generic \
-		distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-recursive
-
-.PHONY: uninstall-dataDATA install-dataDATA install-data-recursive \
-uninstall-data-recursive install-exec-recursive \
-uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
-all-recursive check-recursive installcheck-recursive info-recursive \
-dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
-maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
-dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
-install-exec install-data-am install-data install-am install \
-uninstall-am uninstall all-redirect all-am all installdirs-am \
-installdirs mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
-
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:

+ 1 - 1
data/map/2players.map

@@ -1,4 +1,4 @@
-/* $Id: 2players.map,v 1.4 2001/05/06 18:24:26 kilobug Exp $ */
+
 
 [ header ]
 

+ 1 - 1
data/map/4players.map

@@ -1,4 +1,4 @@
-/* $Id: 4players.map,v 1.4 2001/05/06 18:24:26 kilobug Exp $ */
+
 
 [ header ]
 

+ 1 - 1
data/map/Makefile.am

@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.3 2001/05/06 07:23:34 kilobug Exp $
+
 
 data_DATA	= 2players.map 4players.map pulse-4.map small.map center.map
 EXTRA_DIST	= $(data_DATA)

+ 1 - 1
data/map/Makefile.in

@@ -10,7 +10,7 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-# $Id: Makefile.am,v 1.3 2001/05/06 07:23:34 kilobug Exp $
+
 
 
 SHELL = @SHELL@

+ 1 - 1
data/map/center.map

@@ -1,4 +1,4 @@
-/* $Id: center.map,v 1.2 2001/05/06 08:37:02 kilobug Exp $ */
+
 /* The funky map by Kilobug */
 
 

+ 1 - 1
data/map/pulse-4.map

@@ -1,4 +1,4 @@
-/* $Id: pulse-4.map,v 1.4 2001/05/06 18:24:26 kilobug Exp $ */
+
 
 [ header ]
 

+ 1 - 1
data/map/small.map

@@ -1,4 +1,4 @@
-/* Sample map - $Id: small.map,v 1.4 2001/05/06 18:24:26 kilobug Exp $ */
+
 
 [ header ]
 

+ 12 - 0
doc/CMakeLists.txt

@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(PulsarDoc)
+
+# Building the manpages:
+# groff -t -man -Tlatin1 $< > $@
+
+install(FILES COPYING
+        DESTINATION .)
+
+install(FILES sujet/sujet.tex AUTHORS
+        DESTINATION doc)

+ 0 - 2
doc/ChangeLog

@@ -1,5 +1,3 @@
-# $Id: ChangeLog,v 1.19 2001/05/11 12:25:42 kilobug Exp $
-
 2001-05-11  Kilobug  <le-mig_g@epita.fr>
 
 	* AUTHORS, README: *** empty log message ***

+ 0 - 22
doc/Makefile.am

@@ -1,22 +0,0 @@
-# $Id: Makefile.am,v 1.5 2001/05/04 15:43:44 kilobug Exp $
-
-EXTRA_DIST	= mserver.sql protocole.txt\
-		  server.man gtk-client.man map.man prologin.man bouvier.man\
-		  sujet/Makefile sujet/sujet.tex
-
-man_MANS	= server.1 gtk-client.1 prologin.1 map.5 bouvier.1
-
-server.1: server.man
-	groff -t -man -Tlatin1 $< > $@
-
-gtk-client.1: gtk-client.man
-	groff -t -man -Tlatin1 $< > $@
-
-prologin.1: prologin.man
-	groff -t -man -Tlatin1 $< > $@
-
-map.5: map.man
-	groff -t -man -Tlatin1 $< > $@
-
-bouvier.1: bouvier.man
-	groff -t -man -Tlatin1 $< > $@

+ 0 - 279
doc/Makefile.in

@@ -1,279 +0,0 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-# $Id: Makefile.am,v 1.5 2001/05/04 15:43:44 kilobug Exp $
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-CC = @CC@
-CFLAGS = @CFLAGS@
-GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
-GDK_PIXBUF_CONFIG = @GDK_PIXBUF_CONFIG@
-GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
-GLIB_CFLAGS = @GLIB_CFLAGS@
-GLIB_CONFIG = @GLIB_CONFIG@
-GLIB_LIBS = @GLIB_LIBS@
-GTK_CFLAGS = @GTK_CFLAGS@
-GTK_CONFIG = @GTK_CONFIG@
-GTK_LIBS = @GTK_LIBS@
-LDFLAGS = @LDFLAGS@
-MAKEINFO = @MAKEINFO@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-VERSION = @VERSION@
-
-EXTRA_DIST = mserver.sql protocole.txt 		  server.man gtk-client.man map.man prologin.man bouvier.man 		  sujet/Makefile sujet/sujet.tex
-
-
-man_MANS = server.1 gtk-client.1 prologin.1 map.5 bouvier.1
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../config.h
-CONFIG_CLEAN_FILES = 
-man1dir = $(mandir)/man1
-man5dir = $(mandir)/man5
-MANS = $(man_MANS)
-
-NROFF = nroff
-DIST_COMMON =  Makefile.am Makefile.in TODO
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps doc/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-install-man1:
-	$(mkinstalldirs) $(DESTDIR)$(man1dir)
-	@list='$(man1_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
-	  case "$$i" in \
-	    *.1*) list="$$list $$i" ;; \
-	  esac; \
-	done; \
-	for i in $$list; do \
-	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
-	  else file=$$i; fi; \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \
-	  $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \
-	done
-
-uninstall-man1:
-	@list='$(man1_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
-	  case "$$i" in \
-	    *.1*) list="$$list $$i" ;; \
-	  esac; \
-	done; \
-	for i in $$list; do \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \
-	  rm -f $(DESTDIR)$(man1dir)/$$inst; \
-	done
-
-install-man5:
-	$(mkinstalldirs) $(DESTDIR)$(man5dir)
-	@list='$(man5_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
-	  case "$$i" in \
-	    *.5*) list="$$list $$i" ;; \
-	  esac; \
-	done; \
-	for i in $$list; do \
-	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
-	  else file=$$i; fi; \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man5dir)/$$inst"; \
-	  $(INSTALL_DATA) $$file $(DESTDIR)$(man5dir)/$$inst; \
-	done
-
-uninstall-man5:
-	@list='$(man5_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
-	  case "$$i" in \
-	    *.5*) list="$$list $$i" ;; \
-	  esac; \
-	done; \
-	for i in $$list; do \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " rm -f $(DESTDIR)$(man5dir)/$$inst"; \
-	  rm -f $(DESTDIR)$(man5dir)/$$inst; \
-	done
-install-man: $(MANS)
-	@$(NORMAL_INSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) install-man1 install-man5
-uninstall-man:
-	@$(NORMAL_UNINSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) uninstall-man1 uninstall-man5
-tags: TAGS
-TAGS:
-
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = doc
-
-distdir: $(DISTFILES)
-	$(mkinstalldirs) $(distdir)/sujet
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
-	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
-	  fi; \
-	done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
-
-install-data-am: install-man
-install-data: install-data-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-man
-uninstall: uninstall-am
-all-am: Makefile $(MANS)
-all-redirect: all-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-	$(mkinstalldirs)  $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man5
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am:  distclean-generic clean-am
-
-distclean: distclean-am
-
-maintainer-clean-am:  maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: install-man1 uninstall-man1 install-man5 uninstall-man5 \
-install-man uninstall-man tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
-
-
-server.1: server.man
-	groff -t -man -Tlatin1 $< > $@
-
-gtk-client.1: gtk-client.man
-	groff -t -man -Tlatin1 $< > $@
-
-prologin.1: prologin.man
-	groff -t -man -Tlatin1 $< > $@
-
-map.5: map.man
-	groff -t -man -Tlatin1 $< > $@
-
-bouvier.1: bouvier.man
-	groff -t -man -Tlatin1 $< > $@
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:

+ 0 - 2
doc/TODO

@@ -1,5 +1,3 @@
-# $Id: TODO,v 1.14 2001/05/01 11:56:09 kilobug Exp $
-
 NECESSAIRE
 ----------
 

+ 1 - 0
external/cjson

@@ -0,0 +1 @@
+Subproject commit f50dafc7d0bfd4f45449ab5665bfea831a82f2eb

+ 0 - 0
cmake/CJSON.cmake → external/cmake/CJSON.cmake


+ 0 - 0
cmake/FindCJSON.cmake → external/cmake/FindCJSON.cmake


+ 0 - 0
cmake/GetGitRevisionDescription.cmake → external/cmake/GetGitRevisionDescription.cmake


+ 0 - 0
cmake/GetGitRevisionDescription.cmake.in → external/cmake/GetGitRevisionDescription.cmake.in


+ 1 - 0
external/glfw

@@ -0,0 +1 @@
+Subproject commit 56a4cb0a3a2c7a44a2fd8ab3335adf915e19d30c

+ 1 - 0
external/imgui

@@ -0,0 +1 @@
+Subproject commit ad3f54ff1a8e380fc79079d657ef108fa1cf8e2d

+ 18 - 0
gclient/CMakeLists.txt

@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(PulsarClient)
+
+find_package(CJSON REQUIRED)
+
+set(TARGET gclient)
+
+set(TARGET_HEADER_FILES include/client.h include/client_gtk.h)
+set(TARGET_SOURCE_FILES gamearea.c gen_bigmap.c gen_bigmap2.c gen_minimap.c gtk.c init.c load_map.c main.c mainbox.c
+        map.c menubar.c minimap.c network.c pixbuf.c players.c stats.c statusbar.c toolbar.c)
+
+add_executable(${TARGET} ${TARGET_SOURCE_FILES} ${TARGET_HEADER_FILES})
+
+target_compile_options(${TARGET} PRIVATE -rdynamic)
+target_link_libraries(${TARGET} pulsarnet gtkutil)
+
+install(TARGETS ${TARGET} RUNTIME DESTINATION "bin")

+ 0 - 13
gclient/Makefile.am

@@ -1,13 +0,0 @@
-# $Id: Makefile.am,v 1.14 2001/05/01 11:56:11 kilobug Exp $
-
-INCLUDES		= @GTK_CFLAGS@ @GDK_PIXBUF_CFLAGS@
-
-bin_PROGRAMS		= gtk-client
-gtk_client_SOURCES	= main.c client.h init.c gen_bigmap2.c\
-			  gtk.c client_gtk.h network.c pixbuf.c \
-			  map.c load_map.c gen_minimap.c gen_bigmap.c\
-			  mainbox.c statusbar.c menubar.c toolbar.c \
-			  gamearea.c minimap.c players.c stats.c
-gtk_client_LDADD	= @GDK_PIXBUF_LIBS@ -L../netlib -lnet \
-			  -L../gtkutil -lgtkutil
-gtk_client_DEPENDENCIES	= ../netlib/libnet.a ../gtkutil/libgtkutil.a

+ 50 - 50
gclient/gamearea.c

@@ -1,5 +1,3 @@
-/* $Id: gamearea.c,v 1.16 2001/04/29 22:07:44 kilobug Exp $ */
-
 #include "client.h"
 
 #define ZOOM_ALPHA 40.0
@@ -8,69 +6,71 @@
 
 void gamearea_refresh(GtkWidget *w, conf_t *conf)
 {
-  gdk_draw_rgb_32_image(w->window, 
-			w->style->fg_gc[GTK_STATE_NORMAL],
-			0, 0, MAP_SIZE, MAP_SIZE, 
-			GDK_RGB_DITHER_NORMAL,
-			gen_bigmap(conf, TRUE),
-			MAP_SIZE * 4);
+    gdk_draw_rgb_32_image(w->window,
+                          w->style->fg_gc[GTK_STATE_NORMAL],
+                          0, 0, MAP_SIZE, MAP_SIZE,
+                          GDK_RGB_DITHER_NORMAL,
+                          gen_bigmap(conf, TRUE),
+                          MAP_SIZE * 4);
 }
 
-static gint gamearea_expose_event(GtkWidget *w, GdkEventExpose *e, 
-			      conf_t *conf)
+static gint gamearea_expose_event(GtkWidget *w, GdkEventExpose *e,
+                                  conf_t *conf)
 {
-  guint offs;
+    guint offs;
 
-  offs = (e->area.x + e->area.y * MAP_SIZE) * 4;
-  gdk_draw_rgb_32_image(w->window, 
-			w->style->fg_gc[GTK_WIDGET_STATE(w)],
-			e->area.x, e->area.y, 
-			e->area.width, e->area.height,
-			GDK_RGB_DITHER_NORMAL,
-			gen_bigmap(conf, FALSE) + offs,
-			MAP_SIZE * 4);
-  return FALSE;
+    offs = ( e->area.x + e->area.y * MAP_SIZE ) * 4;
+    gdk_draw_rgb_32_image(w->window,
+                          w->style->fg_gc[GTK_WIDGET_STATE(w)],
+                          e->area.x, e->area.y,
+                          e->area.width, e->area.height,
+                          GDK_RGB_DITHER_NORMAL,
+                          gen_bigmap(conf, FALSE) + offs,
+                          MAP_SIZE * 4);
+    return FALSE;
 }
 
 GtkWidget *create_game_area(conf_t *conf)
 {
-  GtkWidget *frame, *vbox;
+    GtkWidget *frame, *vbox;
 
-  frame = create_frame("Terrain de jeu");
-  vbox = gtk_vbox_new(FALSE, 0);
-  gtk_widget_show(vbox);
-  gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
-  conf->main = gtk_drawing_area_new();
-  gtk_drawing_area_size(GTK_DRAWING_AREA(conf->main),
-			MAP_SIZE, MAP_SIZE);
-  gtk_signal_connect(GTK_OBJECT(conf->main), "expose_event",
-		     (GtkSignalFunc) gamearea_expose_event, conf);
-  gtk_container_add(GTK_CONTAINER(frame), conf->main);
-  gtk_widget_show(conf->main);
+    frame = create_frame("Terrain de jeu");
+    vbox = gtk_vbox_new(FALSE, 0);
+    gtk_widget_show(vbox);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+    conf->main = gtk_drawing_area_new();
+    gtk_drawing_area_size(GTK_DRAWING_AREA(conf->main),
+                          MAP_SIZE, MAP_SIZE);
+    gtk_signal_connect(GTK_OBJECT(conf->main), "expose_event",
+                       (GtkSignalFunc) gamearea_expose_event, conf);
+    gtk_container_add(GTK_CONTAINER(frame), conf->main);
+    gtk_widget_show(conf->main);
 
-  return vbox;
+    return vbox;
 }
 
 void scroll_bigmap(conf_t *conf, float x, float y)
 {
-  float sx, sy;
-  float alpha;
-  int xsize, ysize;
+    float sx, sy;
+    float alpha;
+    int xsize, ysize;
 
-  if (conf->map == NULL)
-    return;
+    if ( conf->map == NULL )
+    {
+        return;
+    }
 
-  alpha = ZOOM_ALPHA / MAX(conf->map->sizex, conf->map->sizey);
-  conf->big_zoom = alpha * exp(ZOOM_BETA * conf->log_big_zoom + ZOOM_GAMMA);
+    alpha = ZOOM_ALPHA / MAX(conf->map->sizex, conf->map->sizey);
+    conf->big_zoom = alpha * exp(ZOOM_BETA * conf->log_big_zoom + ZOOM_GAMMA);
 
-  conf->mini_center_x = x;
-  conf->mini_center_y = y;
-  xsize = conf->map->sizex * conf->big_zoom + 100;
-  ysize = conf->map->sizey * conf->big_zoom + 100;
-  sx = x * xsize / MINI_MAP_SIZE - MAP_SIZE / 2;
-  sy = y * ysize / MINI_MAP_SIZE - MAP_SIZE / 2;
-  conf->big_ofs_x = CLAMP((int) sx, -50, xsize - MAP_SIZE - 50);
-  conf->big_ofs_y = CLAMP((int) sy, -50, ysize - MAP_SIZE - 50); 
-  minimap_refresh(conf->mini, conf);
-  gamearea_refresh(conf->main, conf);
+    conf->mini_center_x = x;
+    conf->mini_center_y = y;
+    xsize = conf->map->sizex * conf->big_zoom + 100;
+    ysize = conf->map->sizey * conf->big_zoom + 100;
+    sx = x * xsize / MINI_MAP_SIZE - MAP_SIZE / 2;
+    sy = y * ysize / MINI_MAP_SIZE - MAP_SIZE / 2;
+    conf->big_ofs_x = CLAMP((int) sx, -50, xsize - MAP_SIZE - 50);
+    conf->big_ofs_y = CLAMP((int) sy, -50, ysize - MAP_SIZE - 50);
+    minimap_refresh(conf->mini, conf);
+    gamearea_refresh(conf->main, conf);
 }

+ 577 - 465
gclient/gen_bigmap.c

@@ -1,548 +1,660 @@
-/* $Id: gen_bigmap.c,v 1.22 2001/04/29 22:07:44 kilobug Exp $ */
-
 #include "client.h"
 
-#define OFFSET2(SX, X, Y)	(((X) + (Y) * (SX)) * 4)
-#define	IRD(SX, X,Y)		(OFFSET2(SX, X, Y) + 0)
-#define	IGR(SX, X,Y)		(OFFSET2(SX, X, Y) + 1)
-#define	IBL(SX, X,Y)		(OFFSET2(SX, X, Y) + 2)
-#define	MASK(SX, X,Y)		(OFFSET2(SX, X, Y) + 3)
+#define OFFSET2(SX, X, Y)    (((X) + (Y) * (SX)) * 4)
+#define    IRD(SX, X, Y)        (OFFSET2(SX, X, Y) + 0)
+#define    IGR(SX, X, Y)        (OFFSET2(SX, X, Y) + 1)
+#define    IBL(SX, X, Y)        (OFFSET2(SX, X, Y) + 2)
+#define    MASK(SX, X, Y)        (OFFSET2(SX, X, Y) + 3)
 
 #define OFFSET(X, Y)    (OFFSET2(MAP_SIZE, X, Y))
-#define	RED(X,Y)	(OFFSET(X, Y) + 0)
-#define	GREEN(X,Y)	(OFFSET(X, Y) + 1)
-#define	BLUE(X,Y)	(OFFSET(X, Y) + 2)
-#define	ID(X,Y)		(OFFSET(X, Y) + 3)
+#define    RED(X, Y)    (OFFSET(X, Y) + 0)
+#define    GREEN(X, Y)    (OFFSET(X, Y) + 1)
+#define    BLUE(X, Y)    (OFFSET(X, Y) + 2)
+#define    ID(X, Y)        (OFFSET(X, Y) + 3)
 
-#define	RED_COLOR(map, id)	((map)->players[(id)]->colors[2])
-#define	GREEN_COLOR(map, id)	((map)->players[(id)]->colors[1])
-#define	BLUE_COLOR(map, id)	((map)->players[(id)]->colors[0])
+#define    RED_COLOR(map, id)    ((map)->players[(id)]->colors[2])
+#define    GREEN_COLOR(map, id)    ((map)->players[(id)]->colors[1])
+#define    BLUE_COLOR(map, id)    ((map)->players[(id)]->colors[0])
 
-#define	CONV_X(map, X)	(((X) * MAP_SIZE) / ((map)->sizex + 0.1))
-#define	CONV_Y(map, Y)	(((Y) * MAP_SIZE) / ((map)->sizey + 0.1))
+#define    CONV_X(map, X)    (((X) * MAP_SIZE) / ((map)->sizex + 0.1))
+#define    CONV_Y(map, Y)    (((Y) * MAP_SIZE) / ((map)->sizey + 0.1))
 
-static void bm_plot_point_ex(guchar *bigmap, guchar id, int x, 
-			     int y, int r, int g, int b)
+static void bm_plot_point_ex(guchar *bigmap, guchar id, int x,
+                             int y, int r, int g, int b)
 {
-  int	offset;
-  
-  offset = OFFSET(x, y);
-  if (bigmap[offset + 3] == id)
-    return;
-
-  bigmap[offset + 3] = id;
-  bigmap[offset + 0] = gl_config->convtb[bigmap[offset + 0] + r * 256];
-  bigmap[offset + 1] = gl_config->convtb[bigmap[offset + 1] + g * 256];
-  bigmap[offset + 2] = gl_config->convtb[bigmap[offset + 2] + b * 256];
+    int offset;
+
+    offset = OFFSET(x, y);
+    if ( bigmap[offset + 3] == id )
+    {
+        return;
+    }
+
+    bigmap[offset + 3] = id;
+    bigmap[offset + 0] = gl_config->convtb[bigmap[offset + 0] + r * 256];
+    bigmap[offset + 1] = gl_config->convtb[bigmap[offset + 1] + g * 256];
+    bigmap[offset + 2] = gl_config->convtb[bigmap[offset + 2] + b * 256];
 }
 
-static void bm_plot_point(guchar *bigmap, int x, int y, 
-			  guchar r, guchar g, guchar b)
+static void bm_plot_point(guchar *bigmap, int x, int y,
+                          guchar r, guchar g, guchar b)
 {
-  int	temp;  
-
-  if ((x < 0) || (x >= MAP_SIZE))
-    return;
-  if ((y < 0) || (y >= MAP_SIZE))
-    return;
-  temp = bigmap[RED(x,y)] + r;
-  if (temp > 0xFF)
-    temp = 0xFF;
-  bigmap[RED(x,y)] = temp;
-
-  temp = bigmap[GREEN(x,y)] + g;
-  if (temp > 0xFF)
-    temp = 0xFF;
-  bigmap[GREEN(x,y)] = temp;
-
-  temp = bigmap[BLUE(x,y)] + b;
-  if (temp > 0xFF)
-    temp = 0xFF;
-  bigmap[BLUE(x,y)] = temp;
+    int temp;
+
+    if (( x < 0 ) || ( x >= MAP_SIZE ))
+    {
+        return;
+    }
+    if (( y < 0 ) || ( y >= MAP_SIZE ))
+    {
+        return;
+    }
+    temp = bigmap[RED(x, y)] + r;
+    if ( temp > 0xFF )
+    {
+        temp = 0xFF;
+    }
+    bigmap[RED(x, y)] = temp;
+
+    temp = bigmap[GREEN(x, y)] + g;
+    if ( temp > 0xFF )
+    {
+        temp = 0xFF;
+    }
+    bigmap[GREEN(x, y)] = temp;
+
+    temp = bigmap[BLUE(x, y)] + b;
+    if ( temp > 0xFF )
+    {
+        temp = 0xFF;
+    }
+    bigmap[BLUE(x, y)] = temp;
 }
 
-static void bm_plot_line(guchar *bigmap, int x1, int y1, int x2, int y2, 
-		      guchar r, guchar g, guchar b)
+static void bm_plot_line(guchar *bigmap, int x1, int y1, int x2, int y2,
+                         guchar r, guchar g, guchar b)
 {
-  float	a;
-  int	diffx, diffy;
-  int	x, y;
-
-  diffx = x1 - x2;
-  diffy = y1 - y2;
-  if (!diffx && !diffy)
-    bm_plot_point(bigmap, x1, y2, r, g, b);
-  else
-    {
-      if (ABS(diffx) > ABS(diffy))
-	{
-	  a = (float)diffy / diffx;
-	  if (x1 > x2)
-	    {
-	      x = x2;
-	      x2 = x1;
-	      x1 = x;
-	      y = y1;
-	      y1 = y2;
-	      y2 = y;
-	    }
-	  else
-	    x = x1;
-	  while (x != x2)
-	    {
-	      bm_plot_point(bigmap, x, y1 + (x - x1) * a, r, g, b);
-	      x++;
-	    }
-	}
-      else
-	{
-	  a = (float)diffx / diffy;
-	  if (y1 > y2)
-	    {
-	      y = y2;
-	      y2 = y1;
-	      y1 = y;
-	      x = x1;
-	      x1 = x2;
-	      x2 = x;
-	    }
-	  else
-	    y = y1;
-	  while (y != y2)
-	    {
-	      bm_plot_point(bigmap, x1 + (y - y1) * a, y, r, g, b);
-	      y++;
-	    }
-	}
+    float a;
+    int diffx, diffy;
+    int x, y;
+
+    diffx = x1 - x2;
+    diffy = y1 - y2;
+    if ( !diffx && !diffy )
+    {
+        bm_plot_point(bigmap, x1, y2, r, g, b);
+    }
+    else
+    {
+        if ( ABS(diffx) > ABS(diffy))
+        {
+            a = (float) diffy / diffx;
+            if ( x1 > x2 )
+            {
+                x = x2;
+                x2 = x1;
+                x1 = x;
+                y = y1;
+                y1 = y2;
+                y2 = y;
+            }
+            else
+            {
+                x = x1;
+            }
+            while ( x != x2 )
+            {
+                bm_plot_point(bigmap, x, y1 + ( x - x1 ) * a, r, g, b);
+                x++;
+            }
+        }
+        else
+        {
+            a = (float) diffx / diffy;
+            if ( y1 > y2 )
+            {
+                y = y2;
+                y2 = y1;
+                y1 = y;
+                x = x1;
+                x1 = x2;
+                x2 = x;
+            }
+            else
+            {
+                y = y1;
+            }
+            while ( y != y2 )
+            {
+                bm_plot_point(bigmap, x1 + ( y - y1 ) * a, y, r, g, b);
+                y++;
+            }
+        }
     }
 }
 
 static float bm_rotate_x(float x, float y, float cs, float sn)
 {
-  return cs * x + sn * y;
+    return cs * x + sn * y;
 }
 
 static float bm_rotate_y(float x, float y, float cs, float sn)
 {
-  return cs * y - sn * x;
+    return cs * y - sn * x;
 }
 
 static int bm_distance(int x1, int y1, int x2, int y2)
-{ 
-  return (SQR(x2 - x1) + SQR(y2 - y1));
+{
+    return ( SQR(x2 - x1) + SQR(y2 - y1));
 }
 
 static void bm_plot_triangle(guchar *bigmap, guchar id,
-			     int x1, int y1, int x2, int y2, int x3, int y3,
-			     int dist, guchar cr, guchar cg, guchar cb)
+                             int x1, int y1, int x2, int y2, int x3, int y3,
+                             int dist, guchar cr, guchar cg, guchar cb)
 {
-  int	swap;
-  float	delta1, delta2, delta3;
-  float	xa, xb, txa, txb;
-  int	x, y, begy, endy;
-  int	memx = x1, memy = y1;
-  int	rac;
-
-  if (y1 > y2) 
-    {
-      swap  = x1;
-      x1    = x2;
-      x2    = swap;
-
-      swap  = y1;
-      y1    = y2;
-      y2    = swap;
-    }
-  if (y1 > y3)
-    {
-      swap  = x3;
-      x3    = x1;
-      x1    = swap;
-
-      swap  = y1;
-      y1    = y3;
-      y3    = swap;
-    }
-  
-  if (y2 > y3) 
-    {
-      swap  = x3;
-      x3    = x2;
-      x2    = swap;
-  
-      swap  = y3;
-      y3    = y2;
-      y2    = swap;
-    }
-
-
-  /* determination des coefficients directeurs */
-  if (y1 != y3)
-    delta1 = ((float)x1-x3)/(y1-y3);  
-  else
-    delta1 = 0;
-  
-  if (y1 != y2)
-    delta2 = ((float)x2-x1)/(y2-y1);
-  else
-    delta2 = 0;
-  
-  if (y2 != y3)  
-    delta3 = ((float)x3-x2)/(y3-y2);
-  else
-    delta3 = 0;
-  
-  /* PremiŠre partie du triangle ( tracage des section horizontale) */
-
-  xa = x1;
-  xb = x1;
-
-  if (y1 != y2)
-    {
-      if (y1 < 0)
-	{
-	  xa -= delta1 * y1;
-	  xb -= delta2 * y1;
-	  begy = 0;
-	}
-      else
-	begy = y1;
-      if (y2 > (MAP_SIZE-1))
-	endy = MAP_SIZE-1;
-      else
-	endy = y2;
-      if (delta1 < delta2)
-	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta2;
-	    txa = MAX(0, xa);
-	    txb = MIN(MAP_SIZE-1, xb);
-	    
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txa = MAX(txa, memx - rac);
-	    txb = MIN(txb, memx + rac);
-
-	    for (x = txa; x < txb; x++)
-	      bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
-      else
-	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta2;
-	    txb = MAX(0, xb);
-	    txa = MIN(MAP_SIZE-1, xa);
-
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txb = MAX(txb, memx - rac);
-	    txa = MIN(txa, memx + rac);
-
-	    for (x = txb; x < txa; x++)
-	      bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
-      xa = x1 + delta1 * (y2 - y1);
-      xb = x1 + delta2 * (y2 - y1);
-    }
-  else 
-    xb = x2;
-
-  /* Deuxieme partie du triangle ( tracage des section horizontale) */
-
-  if (y2 != y3) 
-    {
-      if (y2 < 0)
-	{
-	  xa -= delta1 * y2;
-	  xb -= delta3 * y2;
-	  begy = 0;
-	}
-      else
-	begy = y2;
-      if (y3 > (MAP_SIZE-1))
-	endy = MAP_SIZE-1;
-      else
-	endy = y3;
-      if (delta3 < delta1) 
-	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta3;
-	    txa = MAX(0, xa);
-	    txb = MIN(MAP_SIZE-1, xb);
-	    
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txa = MAX(txa, memx - rac);
-	    txb = MIN(txb, memx + rac);
-
-	    for (x = txa; x < txb; x++)
-	      bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
-      else
- 	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta3;
-	    txb = MAX(0, xb);
-	    txa = MIN(MAP_SIZE-1, xa);
-	    
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txb = MAX(txb, memx - rac);
-	    txa = MIN(txa, memx + rac);
-
-	    for (x = txb; x < txa; x++)
-	      bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
+    int swap;
+    float delta1, delta2, delta3;
+    float xa, xb, txa, txb;
+    int x, y, begy, endy;
+    int memx = x1, memy = y1;
+    int rac;
+
+    if ( y1 > y2 )
+    {
+        swap = x1;
+        x1 = x2;
+        x2 = swap;
+
+        swap = y1;
+        y1 = y2;
+        y2 = swap;
+    }
+    if ( y1 > y3 )
+    {
+        swap = x3;
+        x3 = x1;
+        x1 = swap;
+
+        swap = y1;
+        y1 = y3;
+        y3 = swap;
+    }
+
+    if ( y2 > y3 )
+    {
+        swap = x3;
+        x3 = x2;
+        x2 = swap;
+
+        swap = y3;
+        y3 = y2;
+        y2 = swap;
+    }
+
+
+    /* determination des coefficients directeurs */
+    if ( y1 != y3 )
+    {
+        delta1 = ((float) x1 - x3 ) / ( y1 - y3 );
+    }
+    else
+    {
+        delta1 = 0;
+    }
+
+    if ( y1 != y2 )
+    {
+        delta2 = ((float) x2 - x1 ) / ( y2 - y1 );
+    }
+    else
+    {
+        delta2 = 0;
+    }
+
+    if ( y2 != y3 )
+    {
+        delta3 = ((float) x3 - x2 ) / ( y3 - y2 );
+    }
+    else
+    {
+        delta3 = 0;
+    }
+
+    /* Premi�re partie du triangle ( tracage des section horizontale) */
+
+    xa = x1;
+    xb = x1;
+
+    if ( y1 != y2 )
+    {
+        if ( y1 < 0 )
+        {
+            xa -= delta1 * y1;
+            xb -= delta2 * y1;
+            begy = 0;
+        }
+        else
+        {
+            begy = y1;
+        }
+        if ( y2 > ( MAP_SIZE - 1 ))
+        {
+            endy = MAP_SIZE - 1;
+        }
+        else
+        {
+            endy = y2;
+        }
+        if ( delta1 < delta2 )
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta2;
+                txa = MAX(0, xa);
+                txb = MIN(MAP_SIZE - 1, xb);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txa = MAX(txa, memx - rac);
+                txb = MIN(txb, memx + rac);
+
+                for ( x = txa ; x < txb ; x++ )
+                {
+                    bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
+        else
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta2;
+                txb = MAX(0, xb);
+                txa = MIN(MAP_SIZE - 1, xa);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txb = MAX(txb, memx - rac);
+                txa = MIN(txa, memx + rac);
+
+                for ( x = txb ; x < txa ; x++ )
+                {
+                    bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
+        xa = x1 + delta1 * ( y2 - y1 );
+        xb = x1 + delta2 * ( y2 - y1 );
+    }
+    else
+    {
+        xb = x2;
+    }
+
+    /* Deuxieme partie du triangle ( tracage des section horizontale) */
+
+    if ( y2 != y3 )
+    {
+        if ( y2 < 0 )
+        {
+            xa -= delta1 * y2;
+            xb -= delta3 * y2;
+            begy = 0;
+        }
+        else
+        {
+            begy = y2;
+        }
+        if ( y3 > ( MAP_SIZE - 1 ))
+        {
+            endy = MAP_SIZE - 1;
+        }
+        else
+        {
+            endy = y3;
+        }
+        if ( delta3 < delta1 )
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta3;
+                txa = MAX(0, xa);
+                txb = MIN(MAP_SIZE - 1, xb);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txa = MAX(txa, memx - rac);
+                txb = MIN(txb, memx + rac);
+
+                for ( x = txa ; x < txb ; x++ )
+                {
+                    bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
+        else
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta3;
+                txb = MAX(0, xb);
+                txa = MIN(MAP_SIZE - 1, xa);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txb = MAX(txb, memx - rac);
+                txa = MIN(txa, memx + rac);
+
+                for ( x = txb ; x < txa ; x++ )
+                {
+                    bm_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
     }
 }
 
 
 static void bm_plot_cone(guchar *bigmap, guchar id,
-			 float x1, float y1, float x2, float y2, 
-			 float angle, guchar r, guchar g, guchar b)
+                         float x1, float y1, float x2, float y2,
+                         float angle, guchar r, guchar g, guchar b)
 {
-  float cs, sn, csi;
-  float x, y, xc, xd, yc, yd;
-  gboolean call_sub = FALSE;
-
-  x = x2 - x1;
-  y = y2 - y1;
-  if (angle > M_PI_2)
-    {
-      call_sub = TRUE;
-      angle /= 2;
-    }
-  cs = cos(angle / 2);
-  sn = sin(angle / 2);
-  xc = bm_rotate_x(x, y, cs, sn);
-  xd = bm_rotate_x(x, y, cs, -sn);
-  yc = bm_rotate_y(x, y, cs, sn);
-  yd = bm_rotate_y(x, y, cs, -sn);
-  if (call_sub)
-    {
-      bm_plot_cone(bigmap, id, x1, y1, xc + x1, yc + y1, angle, r, g, b);
-      bm_plot_cone(bigmap, id, x1, y1, xd + x1, yd + y1, angle, r, g, b);
-      return;
-    }
-  csi = 1 / cs;
-  xc = xc * csi + x1;
-  xd = xd * csi + x1;
-  yc = yc * csi + y1;
-  yd = yd * csi + y1;
-  bm_plot_triangle(bigmap, id, x1, y1, xc, yc, xd, yd, 
-		   bm_distance(x1, y1, x2, y2), r, g, b);
+    float cs, sn, csi;
+    float x, y, xc, xd, yc, yd;
+    bool call_sub = FALSE;
+
+    x = x2 - x1;
+    y = y2 - y1;
+    if ( angle > M_PI_2 )
+    {
+        call_sub = TRUE;
+        angle /= 2;
+    }
+    cs = cos(angle / 2);
+    sn = sin(angle / 2);
+    xc = bm_rotate_x(x, y, cs, sn);
+    xd = bm_rotate_x(x, y, cs, -sn);
+    yc = bm_rotate_y(x, y, cs, sn);
+    yd = bm_rotate_y(x, y, cs, -sn);
+    if ( call_sub )
+    {
+        bm_plot_cone(bigmap, id, x1, y1, xc + x1, yc + y1, angle, r, g, b);
+        bm_plot_cone(bigmap, id, x1, y1, xd + x1, yd + y1, angle, r, g, b);
+        return;
+    }
+    csi = 1 / cs;
+    xc = xc * csi + x1;
+    xd = xd * csi + x1;
+    yc = yc * csi + y1;
+    yd = yd * csi + y1;
+    bm_plot_triangle(bigmap, id, x1, y1, xc, yc, xd, yd,
+                     bm_distance(x1, y1, x2, y2), r, g, b);
 }
 
 static void plot_sprite(guchar *bigmap, const image_t *img, int x, int y)
 {
-  int	x1, y1, sx, sy, ex, ey;
-  const int *src;
-  int *dst;
-
-  if (img == NULL)
-    return;
-
-  x -= img->sx / 2;
-  y -= img->sy / 2;
-  if ((x + img->sx < 0) || (x >= MAP_SIZE))
-    return;
-  if ((y + img->sy < 0) || (y >= MAP_SIZE))
-    return; 
-  
-  src = (void *) img->data;
-  dst = (void *) bigmap;
-
-  dst += x + y * MAP_SIZE;
-  sy = MAX(-y, 0); 
-  sx = MAX(-x, 0); 
-  ey = MIN(img->sy, MAP_SIZE - y); 
-  ex = MIN(img->sx, MAP_SIZE - x); 
-  for (y1 = sy; y1 < ey; y1++)
-    for (x1 = sx; x1 < ex; x1++)
-      if (img->data[MASK(img->sx, x1, y1)] == 0)
-	dst[y1 * MAP_SIZE + x1] = src[y1 * img->sx + x1];
+    int x1, y1, sx, sy, ex, ey;
+    const int *src;
+    int *dst;
+
+    if ( img == NULL )
+    {
+        return;
+    }
+
+    x -= img->sx / 2;
+    y -= img->sy / 2;
+    if (( x + img->sx < 0 ) || ( x >= MAP_SIZE ))
+    {
+        return;
+    }
+    if (( y + img->sy < 0 ) || ( y >= MAP_SIZE ))
+    {
+        return;
+    }
+
+    src = (void *) img->data;
+    dst = (void *) bigmap;
+
+    dst += x + y * MAP_SIZE;
+    sy = MAX(-y, 0);
+    sx = MAX(-x, 0);
+    ey = MIN(img->sy, MAP_SIZE - y);
+    ex = MIN(img->sx, MAP_SIZE - x);
+    for ( y1 = sy ; y1 < ey ; y1++ )
+    {
+        for ( x1 = sx ; x1 < ex ; x1++ )
+        {
+            if ( img->data[MASK(img->sx, x1, y1)] == 0 )
+            {
+                dst[y1 * MAP_SIZE + x1] = src[y1 * img->sx + x1];
+            }
+        }
+    }
 }
 
-static void bm_plot_object(const conf_t *conf, const obj_t *obj, 
-			   guchar *bigmap, const image_t *sprite)
+static void bm_plot_object(const conf_t *conf, const obj_t *obj,
+                           guchar *bigmap, const image_t *sprite)
 {
-  int x, y;
+    int x, y;
 
-  x = obj->posx * conf->big_zoom - conf->big_ofs_x;
-  y = obj->posy * conf->big_zoom - conf->big_ofs_y;
-  plot_sprite(bigmap, sprite, x, y);
+    x = obj->posx * conf->big_zoom - conf->big_ofs_x;
+    y = obj->posy * conf->big_zoom - conf->big_ofs_y;
+    plot_sprite(bigmap, sprite, x, y);
 }
 
 static void bm_plot_r4d2(const conf_t *conf, const obj_t *obj, guchar *bigmap)
-{  
-  int tid;
+{
+    int tid;
 
-  tid = obj->team_id;
-  if (tid > conf->map->nb_players)
-    tid = 0;
-  bm_plot_object(conf, obj, bigmap, conf->map->players[tid]->r4d2);
+    tid = obj->team_id;
+    if ( tid > conf->map->nb_players )
+    {
+        tid = 0;
+    }
+    bm_plot_object(conf, obj, bigmap, conf->map->players[tid]->r4d2);
 }
 
 static void bm_plot_pulse(guchar *bigmap, const conf_t *conf,
-			  const obj_t *obj, guchar *colors)
+                          const obj_t *obj, guchar *colors)
 {
-  float	x, y, x2, y2;
-  int	id;
-
-  id = obj->team_id;
-  x = obj->posx * conf->big_zoom - conf->big_ofs_x;
-  y = obj->posy * conf->big_zoom - conf->big_ofs_y;
-  x2 = obj->tx * conf->big_zoom - conf->big_ofs_x;
-  y2 = obj->ty * conf->big_zoom - conf->big_ofs_y;
-  
-  bm_plot_cone(bigmap, (guchar)obj->id+1, x, y, x2, y2, 
-	       obj->angle,
-	       conf->map->players[id]->colors[2] * 0.3667 * 1.5,
-	       conf->map->players[id]->colors[1] * 0.1864 * 1.5,
-	       conf->map->players[id]->colors[0]);
+    float x, y, x2, y2;
+    int id;
+
+    id = obj->team_id;
+    x = obj->posx * conf->big_zoom - conf->big_ofs_x;
+    y = obj->posy * conf->big_zoom - conf->big_ofs_y;
+    x2 = obj->tx * conf->big_zoom - conf->big_ofs_x;
+    y2 = obj->ty * conf->big_zoom - conf->big_ofs_y;
+
+    bm_plot_cone(bigmap, (guchar) obj->id + 1, x, y, x2, y2,
+                 obj->angle,
+                 conf->map->players[id]->colors[2] * 0.3667 * 1.5,
+                 conf->map->players[id]->colors[1] * 0.1864 * 1.5,
+                 conf->map->players[id]->colors[0]);
 }
 
-static void bm_plot_link(guchar *bigmap, const conf_t *conf, 
-			 const obj_t *obj, guchar *colors)
+static void bm_plot_link(guchar *bigmap, const conf_t *conf,
+                         const obj_t *obj, guchar *colors)
 {
-  int x, y, x2, y2;
+    int x, y, x2, y2;
 
-  x = obj->posx * conf->big_zoom - conf->big_ofs_x;
-  y = obj->posy * conf->big_zoom - conf->big_ofs_y;
-  x2 = conf->map->objects[obj->target]->posx * 
-    conf->big_zoom - conf->big_ofs_x;
-  y2 = conf->map->objects[obj->target]->posy * 
-    conf->big_zoom - conf->big_ofs_y;
+    x = obj->posx * conf->big_zoom - conf->big_ofs_x;
+    y = obj->posy * conf->big_zoom - conf->big_ofs_y;
+    x2 = conf->map->objects[obj->target]->posx *
+         conf->big_zoom - conf->big_ofs_x;
+    y2 = conf->map->objects[obj->target]->posy *
+         conf->big_zoom - conf->big_ofs_y;
 
-  bm_plot_line(bigmap, x, y, x2, y2, colors[2], colors[1], colors[0]);
+    bm_plot_line(bigmap, x, y, x2, y2, colors[2], colors[1], colors[0]);
 }
 
 static void bm_plot_akx(const conf_t *conf, const obj_t *obj, guchar *bigmap)
 {
-  int tid;
+    int tid;
 
-  tid = obj->team_id;
-  if (tid > conf->map->nb_players)
-    tid = 0;
-  bm_plot_object(conf, obj, bigmap, conf->map->players[tid]->akx);
+    tid = obj->team_id;
+    if ( tid > conf->map->nb_players )
+    {
+        tid = 0;
+    }
+    bm_plot_object(conf, obj, bigmap, conf->map->players[tid]->akx);
 }
 
-static void bm_plot_pulse_link(const conf_t *conf, const obj_t *obj, 
-			       guchar *bigmap)
+static void bm_plot_pulse_link(const conf_t *conf, const obj_t *obj,
+                               guchar *bigmap)
 {
-  int tid;
-
-  tid = obj->team_id;
-  if (tid > conf->map->nb_players)
-    tid = 0;
-  /* affichage pulse */
-  if (obj->action == act_akx_pulse)
-    bm_plot_pulse(bigmap, conf, obj, conf->map->players[tid]->colors);
-  
-  /* affichage link */
-  if (obj->action == act_akx_link)
-    bm_plot_link(bigmap, conf, obj, conf->map->players[tid]->colors);
+    int tid;
+
+    tid = obj->team_id;
+    if ( tid > conf->map->nb_players )
+    {
+        tid = 0;
+    }
+    /* affichage pulse */
+    if ( obj->action == act_akx_pulse )
+    {
+        bm_plot_pulse(bigmap, conf, obj, conf->map->players[tid]->colors);
+    }
+
+    /* affichage link */
+    if ( obj->action == act_akx_link )
+    {
+        bm_plot_link(bigmap, conf, obj, conf->map->players[tid]->colors);
+    }
 }
 
 static void plot_pic_block(guchar *dest, image_t *src, int x, int ox, int oy)
 {
-  int y, size, rox = 0;
-  int so, rsx;
-
-  if (x == 0)
-    rox = ox;
-  else
-    dest += (x * src->sx - ox) * 4;
-
-  size = MIN(MAP_SIZE - x * src->sx + ox, src->sx - rox) * 4;
-  if (size <= 0)
-    return;
-
-  so = (oy * src->sx + rox) * 4;
-  rsx = src->sx * 4;
-  for (y = 0; y < src->sy - oy; y++, so += rsx)
-    memcpy(dest + y * MAP_SIZE * 4, src->data + so, size);
-  so = rox * 4;
-  for (; y < src->sy; y++, so += rsx)
-    memcpy(dest + y * MAP_SIZE * 4, src->data + so, size);
+    int y, size, rox = 0;
+    int so, rsx;
+
+    if ( x == 0 )
+    {
+        rox = ox;
+    }
+    else
+    {
+        dest += ( x * src->sx - ox ) * 4;
+    }
+
+    size = MIN(MAP_SIZE - x * src->sx + ox, src->sx - rox) * 4;
+    if ( size <= 0 )
+    {
+        return;
+    }
+
+    so = ( oy * src->sx + rox ) * 4;
+    rsx = src->sx * 4;
+    for ( y = 0 ; y < src->sy - oy ; y++, so += rsx )
+    {
+        memcpy(dest + y * MAP_SIZE * 4, src->data + so, size);
+    }
+    so = rox * 4;
+    for ( ; y < src->sy ; y++, so += rsx )
+    {
+        memcpy(dest + y * MAP_SIZE * 4, src->data + so, size);
+    }
 }
 
 static void plot_background(guchar *bigmap, image_t *fond, int ox, int oy)
 {
-  int	x, y, size;
+    int x, y, size;
+
+    if ( fond == NULL )
+    {
+        return;
+    }
 
-  if (fond == NULL)
-    return;
-  
-  /* Calcul des offsets réels */
-  oy = oy % (fond->sy);
-  while (oy < 0)
-    oy += fond->sy;
-  ox = ox % (fond->sx);
-  while (ox < 0)
-    ox += fond->sx;
+    /* Calcul des offsets r�els */
+    oy = oy % ( fond->sy );
+    while ( oy < 0 )
+    {
+        oy += fond->sy;
+    }
+    ox = ox % ( fond->sx );
+    while ( ox < 0 )
+    {
+        ox += fond->sx;
+    }
 
-  /* First block line */
-  for (x = 0; x <= MAP_SIZE / fond->sx + 1; x++)
-    plot_pic_block(bigmap, fond, x, ox, oy);
+    /* First block line */
+    for ( x = 0 ; x <= MAP_SIZE / fond->sx + 1 ; x++ )
+    {
+        plot_pic_block(bigmap, fond, x, ox, oy);
+    }
 
-  /* Other lines */
-  for (y = 1; y <= MAP_SIZE / fond->sy; y++)
+    /* Other lines */
+    for ( y = 1 ; y <= MAP_SIZE / fond->sy ; y++ )
     {
-      size = MAP_SIZE * MIN(fond->sy, MAP_SIZE - y * fond->sy) * 4;
-      memcpy(bigmap + y * fond->sy * MAP_SIZE * 4, bigmap, size);
+        size = MAP_SIZE * MIN(fond->sy, MAP_SIZE - y * fond->sy) * 4;
+        memcpy(bigmap + y * fond->sy * MAP_SIZE * 4, bigmap, size);
     }
 }
 
-guchar *gen_bigmap(conf_t *conf, gboolean force)
+guchar *gen_bigmap(conf_t *conf, bool force)
 {
-  int			cpt;
-  obj_t			*obj;
-  image_t		*background;
-
-  if (conf->big_radar)
-    return gen_bigmap2(conf, force);
-  background = conf->background;
-  if (conf->map != NULL)
-    if (conf->map->background != NULL)
-      background = conf->map->background;
-  if (conf->screen == NULL)
-    {
-      conf->screen = g_malloc(4 * SQR(MAP_SIZE));
-      plot_background(conf->screen, background, conf->big_ofs_x, 
-		      conf->big_ofs_y);
-    }
-  if (!force)
-    return conf->screen;
-  if (conf->map == NULL)
+    int cpt;
+    obj_t *obj;
+    image_t *background;
+
+    if ( conf->big_radar )
+    {
+        return gen_bigmap2(conf, force);
+    }
+    background = conf->background;
+    if ( conf->map != NULL )
+    {
+        if ( conf->map->background != NULL )
+        {
+            background = conf->map->background;
+        }
+    }
+    if ( conf->screen == NULL )
+    {
+        conf->screen = g_malloc(4 * SQR(MAP_SIZE));
+        plot_background(conf->screen, background, conf->big_ofs_x,
+                        conf->big_ofs_y);
+    }
+    if ( !force )
+    {
+        return conf->screen;
+    }
+    if ( conf->map == NULL )
+    {
+        return conf->screen;
+    }
+    plot_background(conf->screen, background, conf->big_ofs_x,
+                    conf->big_ofs_y);
+
+    if ( conf->big_pulse )
+    {
+        for ( cpt = 0 ; cpt < conf->map->nb_objects ; cpt++ )
+        {
+            obj = conf->map->objects[cpt];
+            if ( obj->type == obj_akx )
+            {
+                bm_plot_pulse_link(conf, obj, conf->screen);
+            }
+        }
+    }
+
+    for ( cpt = 0 ; cpt < conf->map->nb_objects ; cpt++ )
+    {
+        obj = conf->map->objects[cpt];
+        switch ( obj->type )
+        {
+        case obj_r4d2 :
+            bm_plot_r4d2(conf, obj, conf->screen);
+            break;
+        case obj_akx :
+            bm_plot_akx(conf, obj, conf->screen);
+            break;
+        }
+    }
     return conf->screen;
-  plot_background(conf->screen, background, conf->big_ofs_x, 
-		  conf->big_ofs_y);
-
-  if (conf->big_pulse)
-    for (cpt = 0; cpt < conf->map->nb_objects; cpt++)
-      {
-	obj = conf->map->objects[cpt];
-	if (obj->type == obj_akx)
-	  bm_plot_pulse_link(conf, obj, conf->screen); 
-      }
-
-  for (cpt = 0; cpt < conf->map->nb_objects; cpt++)
-    {
-      obj = conf->map->objects[cpt];
-      switch (obj->type)
-	{
-	case obj_r4d2 :
-	  bm_plot_r4d2(conf, obj, conf->screen);
-	  break;
-	case obj_akx :
-	  bm_plot_akx(conf, obj, conf->screen);
-	  break;
-	}
-    }
-  return conf->screen;
 }

+ 497 - 415
gclient/gen_bigmap2.c

@@ -1,485 +1,567 @@
-/* $Id: gen_bigmap2.c,v 1.3 2001/04/24 08:31:29 glop Exp $ */
-
 #include "client.h"
 
-#define OFFSET2(SX, X, Y)	(((X) + (Y) * (SX)) * 4)
-#define	IRD(SX, X,Y)		(OFFSET2(SX, X, Y) + 0)
-#define	IGR(SX, X,Y)		(OFFSET2(SX, X, Y) + 1)
-#define	IBL(SX, X,Y)		(OFFSET2(SX, X, Y) + 2)
-#define	MASK(SX, X,Y)		(OFFSET2(SX, X, Y) + 3)
+#define OFFSET2(SX, X, Y)    (((X) + (Y) * (SX)) * 4)
+#define    IRD(SX, X, Y)        (OFFSET2(SX, X, Y) + 0)
+#define    IGR(SX, X, Y)        (OFFSET2(SX, X, Y) + 1)
+#define    IBL(SX, X, Y)        (OFFSET2(SX, X, Y) + 2)
+#define    MASK(SX, X, Y)        (OFFSET2(SX, X, Y) + 3)
 
 #define OFFSET(X, Y)    (OFFSET2(MAP_SIZE, X, Y))
-#define	RED(X,Y)	(OFFSET(X, Y) + 0)
-#define	GREEN(X,Y)	(OFFSET(X, Y) + 1)
-#define	BLUE(X,Y)	(OFFSET(X, Y) + 2)
-#define	ID(X,Y)		(OFFSET(X, Y) + 3)
+#define    RED(X, Y)    (OFFSET(X, Y) + 0)
+#define    GREEN(X, Y)    (OFFSET(X, Y) + 1)
+#define    BLUE(X, Y)    (OFFSET(X, Y) + 2)
+#define    ID(X, Y)        (OFFSET(X, Y) + 3)
 
-#define	RED_COLOR(map, id)	((map)->players[(id)]->colors[2])
-#define	GREEN_COLOR(map, id)	((map)->players[(id)]->colors[1])
-#define	BLUE_COLOR(map, id)	((map)->players[(id)]->colors[0])
+#define    RED_COLOR(map, id)    ((map)->players[(id)]->colors[2])
+#define    GREEN_COLOR(map, id)    ((map)->players[(id)]->colors[1])
+#define    BLUE_COLOR(map, id)    ((map)->players[(id)]->colors[0])
 
-#define	CONV_X(map, X)	(((X) * MAP_SIZE) / ((map)->sizex + 0.1))
-#define	CONV_Y(map, Y)	(((Y) * MAP_SIZE) / ((map)->sizey + 0.1))
+#define    CONV_X(map, X)    (((X) * MAP_SIZE) / ((map)->sizex + 0.1))
+#define    CONV_Y(map, Y)    (((Y) * MAP_SIZE) / ((map)->sizey + 0.1))
 
-static void bm2_plot_point_ex(guchar *bigmap, guchar id, int x, 
-			     int y, guchar r, guchar g, guchar b)
+static void bm2_plot_point_ex(guchar *bigmap, guchar id, int x,
+                              int y, guchar r, guchar g, guchar b)
 {
-  int	temp;  
-  
-  if (bigmap[ID(x, y)] == id)
-    return;
-
-  temp = bigmap[RED(x,y)] + r;
-  if (temp > PULSE_SAT)
-    temp = PULSE_SAT;
-  bigmap[RED(x,y)] = temp;
-  
-  temp = bigmap[GREEN(x,y)] + g;
-  if (temp > PULSE_SAT)
-    temp = PULSE_SAT;
-  bigmap[GREEN(x,y)] = temp;
-  
-  temp = bigmap[BLUE(x,y)] + b;
-  if (temp > PULSE_SAT)
-    temp = PULSE_SAT;
-  bigmap[BLUE(x,y)] = temp;
-  bigmap[ID(x, y)] = id;
+    int temp;
+
+    if ( bigmap[ID(x, y)] == id )
+    {
+        return;
+    }
+
+    temp = bigmap[RED(x, y)] + r;
+    if ( temp > PULSE_SAT )
+    {
+        temp = PULSE_SAT;
+    }
+    bigmap[RED(x, y)] = temp;
+
+    temp = bigmap[GREEN(x, y)] + g;
+    if ( temp > PULSE_SAT )
+    {
+        temp = PULSE_SAT;
+    }
+    bigmap[GREEN(x, y)] = temp;
+
+    temp = bigmap[BLUE(x, y)] + b;
+    if ( temp > PULSE_SAT )
+    {
+        temp = PULSE_SAT;
+    }
+    bigmap[BLUE(x, y)] = temp;
+    bigmap[ID(x, y)] = id;
 }
 
-static void bm2_plot_point(guchar *bigmap, int x, int y, 
-			  guchar r, guchar g, guchar b)
+static void bm2_plot_point(guchar *bigmap, int x, int y,
+                           guchar r, guchar g, guchar b)
 {
-  int	temp;  
-
-  if ((x < 0) || (x >= MAP_SIZE))
-    return;
-  if ((y < 0) || (y >= MAP_SIZE))
-    return;
-  temp = bigmap[RED(x,y)] + r;
-  if (temp > 0xFF)
-    temp = 0xFF;
-  bigmap[RED(x,y)] = temp;
-
-  temp = bigmap[GREEN(x,y)] + g;
-  if (temp > 0xFF)
-    temp = 0xFF;
-  bigmap[GREEN(x,y)] = temp;
-
-  temp = bigmap[BLUE(x,y)] + b;
-  if (temp > 0xFF)
-    temp = 0xFF;
-  bigmap[BLUE(x,y)] = temp;
+    int temp;
+
+    if (( x < 0 ) || ( x >= MAP_SIZE ))
+    {
+        return;
+    }
+    if (( y < 0 ) || ( y >= MAP_SIZE ))
+    {
+        return;
+    }
+    temp = bigmap[RED(x, y)] + r;
+    if ( temp > 0xFF )
+    {
+        temp = 0xFF;
+    }
+    bigmap[RED(x, y)] = temp;
+
+    temp = bigmap[GREEN(x, y)] + g;
+    if ( temp > 0xFF )
+    {
+        temp = 0xFF;
+    }
+    bigmap[GREEN(x, y)] = temp;
+
+    temp = bigmap[BLUE(x, y)] + b;
+    if ( temp > 0xFF )
+    {
+        temp = 0xFF;
+    }
+    bigmap[BLUE(x, y)] = temp;
 }
 
-static void bm2_plot_line(guchar *bigmap, int x1, int y1, int x2, int y2, 
-		      guchar r, guchar g, guchar b)
+static void bm2_plot_line(guchar *bigmap, int x1, int y1, int x2, int y2,
+                          guchar r, guchar g, guchar b)
 {
-  float	a;
-  int	diffx, diffy;
-  int	x, y;
-
-  diffx = x1 - x2;
-  diffy = y1 - y2;
-  if (!diffx && !diffy)
-    bm2_plot_point(bigmap, x1, y2, r, g, b);
-  else
-    {
-      if (ABS(diffx) > ABS(diffy))
-	{
-	  a = (float)diffy / diffx;
-	  if (x1 > x2)
-	    {
-	      x = x2;
-	      x2 = x1;
-	      x1 = x;
-	      y = y1;
-	      y1 = y2;
-	      y2 = y;
-	    }
-	  else
-	    x = x1;
-	  while (x != x2)
-	    {
-	      bm2_plot_point(bigmap, x, y1 + (x - x1) * a, r, g, b);
-	      x++;
-	    }
-	}
-      else
-	{
-	  a = (float)diffx / diffy;
-	  if (y1 > y2)
-	    {
-	      y = y2;
-	      y2 = y1;
-	      y1 = y;
-	      x = x1;
-	      x1 = x2;
-	      x2 = x;
-	    }
-	  else
-	    y = y1;
-	  while (y != y2)
-	    {
-	      bm2_plot_point(bigmap, x1 + (y - y1) * a, y, r, g, b);
-	      y++;
-	    }
-	}
+    float a;
+    int diffx, diffy;
+    int x, y;
+
+    diffx = x1 - x2;
+    diffy = y1 - y2;
+    if ( !diffx && !diffy )
+    {
+        bm2_plot_point(bigmap, x1, y2, r, g, b);
+    }
+    else
+    {
+        if ( ABS(diffx) > ABS(diffy))
+        {
+            a = (float) diffy / diffx;
+            if ( x1 > x2 )
+            {
+                x = x2;
+                x2 = x1;
+                x1 = x;
+                y = y1;
+                y1 = y2;
+                y2 = y;
+            }
+            else
+            {
+                x = x1;
+            }
+            while ( x != x2 )
+            {
+                bm2_plot_point(bigmap, x, y1 + ( x - x1 ) * a, r, g, b);
+                x++;
+            }
+        }
+        else
+        {
+            a = (float) diffx / diffy;
+            if ( y1 > y2 )
+            {
+                y = y2;
+                y2 = y1;
+                y1 = y;
+                x = x1;
+                x1 = x2;
+                x2 = x;
+            }
+            else
+            {
+                y = y1;
+            }
+            while ( y != y2 )
+            {
+                bm2_plot_point(bigmap, x1 + ( y - y1 ) * a, y, r, g, b);
+                y++;
+            }
+        }
     }
 }
 
 static float bm2_rotate_x(float x, float y, float cs, float sn)
 {
-  return cs * x + sn * y;
+    return cs * x + sn * y;
 }
 
 static float bm2_rotate_y(float x, float y, float cs, float sn)
 {
-  return cs * y - sn * x;
+    return cs * y - sn * x;
 }
 
 static int bm2_distance(int x1, int y1, int x2, int y2)
-{ 
-  return (SQR(x2 - x1) + SQR(y2 - y1));
+{
+    return ( SQR(x2 - x1) + SQR(y2 - y1));
 }
 
 static void bm2_plot_triangle(guchar *bigmap, guchar id,
-			     int x1, int y1, int x2, int y2, int x3, int y3,
-			     int dist, guchar cr, guchar cg, guchar cb)
+                              int x1, int y1, int x2, int y2, int x3, int y3,
+                              int dist, guchar cr, guchar cg, guchar cb)
 {
-  int	swap;
-  float	delta1, delta2, delta3;
-  float	xa, xb, txa, txb;
-  int	x, y, begy, endy;
-  int	memx = x1, memy = y1;
-  int	rac;
-
-  if (y1 > y2) 
-    {
-      swap  = x1;
-      x1    = x2;
-      x2    = swap;
-
-      swap  = y1;
-      y1    = y2;
-      y2    = swap;
-    }
-  if (y1 > y3)
-    {
-      swap  = x3;
-      x3    = x1;
-      x1    = swap;
-
-      swap  = y1;
-      y1    = y3;
-      y3    = swap;
-    }
-  
-  if (y2 > y3) 
-    {
-      swap  = x3;
-      x3    = x2;
-      x2    = swap;
-  
-      swap  = y3;
-      y3    = y2;
-      y2    = swap;
-    }
-
-
-  /* determination des coefficients directeurs */
-  if (y1 != y3)
-    delta1 = ((float)x1-x3)/(y1-y3);  
-  else
-    delta1 = 0;
-  
-  if (y1 != y2)
-    delta2 = ((float)x2-x1)/(y2-y1);
-  else
-    delta2 = 0;
-  
-  if (y2 != y3)  
-    delta3 = ((float)x3-x2)/(y3-y2);
-  else
-    delta3 = 0;
-  
-  /* PremiŠre partie du triangle ( tracage des section horizontale) */
-
-  xa = x1;
-  xb = x1;
-
-  if (y1 != y2)
-    {
-      if (y1 < 0)
-	{
-	  xa -= delta1 * y1;
-	  xb -= delta2 * y1;
-	  begy = 0;
-	}
-      else
-	begy = y1;
-      if (y2 > (MAP_SIZE-1))
-	endy = MAP_SIZE-1;
-      else
-	endy = y2;
-      if (delta1 < delta2)
-	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta2;
-	    txa = MAX(0, xa);
-	    txb = MIN(MAP_SIZE-1, xb);
-	    
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txa = MAX(txa, memx - rac);
-	    txb = MIN(txb, memx + rac);
-
-	    for (x = txa; x < txb; x++)
-	      bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
-      else
-	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta2;
-	    txb = MAX(0, xb);
-	    txa = MIN(MAP_SIZE-1, xa);
-
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txb = MAX(txb, memx - rac);
-	    txa = MIN(txa, memx + rac);
-
-	    for (x = txb; x < txa; x++)
-	      bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
-      xa = x1 + delta1 * (y2 - y1);
-      xb = x1 + delta2 * (y2 - y1);
-    }
-  else 
-    xb = x2;
-
-  /* Deuxieme partie du triangle ( tracage des section horizontale) */
-
-  if (y2 != y3) 
-    {
-      if (y2 < 0)
-	{
-	  xa -= delta1 * y2;
-	  xb -= delta3 * y2;
-	  begy = 0;
-	}
-      else
-	begy = y2;
-      if (y3 > (MAP_SIZE-1))
-	endy = MAP_SIZE-1;
-      else
-	endy = y3;
-      if (delta3 < delta1) 
-	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta3;
-	    txa = MAX(0, xa);
-	    txb = MIN(MAP_SIZE-1, xb);
-	    
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txa = MAX(txa, memx - rac);
-	    txb = MIN(txb, memx + rac);
-
-	    for (x = txa; x < txb; x++)
-	      bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
-      else
- 	for (y = begy; y < endy; y++)
-	  {
-	    xa = xa + delta1;
-	    xb = xb + delta3;
-	    txb = MAX(0, xb);
-	    txa = MIN(MAP_SIZE-1, xa);
-	    
-	    rac = sqrt(dist - SQR(y - memy));
-	    
-	    txb = MAX(txb, memx - rac);
-	    txa = MIN(txa, memx + rac);
-
-	    for (x = txb; x < txa; x++)
-	      bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
-	  }
+    int swap;
+    float delta1, delta2, delta3;
+    float xa, xb, txa, txb;
+    int x, y, begy, endy;
+    int memx = x1, memy = y1;
+    int rac;
+
+    if ( y1 > y2 )
+    {
+        swap = x1;
+        x1 = x2;
+        x2 = swap;
+
+        swap = y1;
+        y1 = y2;
+        y2 = swap;
+    }
+    if ( y1 > y3 )
+    {
+        swap = x3;
+        x3 = x1;
+        x1 = swap;
+
+        swap = y1;
+        y1 = y3;
+        y3 = swap;
+    }
+
+    if ( y2 > y3 )
+    {
+        swap = x3;
+        x3 = x2;
+        x2 = swap;
+
+        swap = y3;
+        y3 = y2;
+        y2 = swap;
+    }
+
+
+    /* determination des coefficients directeurs */
+    if ( y1 != y3 )
+    {
+        delta1 = ((float) x1 - x3 ) / ( y1 - y3 );
+    }
+    else
+    {
+        delta1 = 0;
+    }
+
+    if ( y1 != y2 )
+    {
+        delta2 = ((float) x2 - x1 ) / ( y2 - y1 );
+    }
+    else
+    {
+        delta2 = 0;
+    }
+
+    if ( y2 != y3 )
+    {
+        delta3 = ((float) x3 - x2 ) / ( y3 - y2 );
+    }
+    else
+    {
+        delta3 = 0;
+    }
+
+    /* Premi�re partie du triangle ( tracage des section horizontale) */
+
+    xa = x1;
+    xb = x1;
+
+    if ( y1 != y2 )
+    {
+        if ( y1 < 0 )
+        {
+            xa -= delta1 * y1;
+            xb -= delta2 * y1;
+            begy = 0;
+        }
+        else
+        {
+            begy = y1;
+        }
+        if ( y2 > ( MAP_SIZE - 1 ))
+        {
+            endy = MAP_SIZE - 1;
+        }
+        else
+        {
+            endy = y2;
+        }
+        if ( delta1 < delta2 )
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta2;
+                txa = MAX(0, xa);
+                txb = MIN(MAP_SIZE - 1, xb);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txa = MAX(txa, memx - rac);
+                txb = MIN(txb, memx + rac);
+
+                for ( x = txa ; x < txb ; x++ )
+                {
+                    bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
+        else
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta2;
+                txb = MAX(0, xb);
+                txa = MIN(MAP_SIZE - 1, xa);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txb = MAX(txb, memx - rac);
+                txa = MIN(txa, memx + rac);
+
+                for ( x = txb ; x < txa ; x++ )
+                {
+                    bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
+        xa = x1 + delta1 * ( y2 - y1 );
+        xb = x1 + delta2 * ( y2 - y1 );
+    }
+    else
+    {
+        xb = x2;
+    }
+
+    /* Deuxieme partie du triangle ( tracage des section horizontale) */
+
+    if ( y2 != y3 )
+    {
+        if ( y2 < 0 )
+        {
+            xa -= delta1 * y2;
+            xb -= delta3 * y2;
+            begy = 0;
+        }
+        else
+        {
+            begy = y2;
+        }
+        if ( y3 > ( MAP_SIZE - 1 ))
+        {
+            endy = MAP_SIZE - 1;
+        }
+        else
+        {
+            endy = y3;
+        }
+        if ( delta3 < delta1 )
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta3;
+                txa = MAX(0, xa);
+                txb = MIN(MAP_SIZE - 1, xb);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txa = MAX(txa, memx - rac);
+                txb = MIN(txb, memx + rac);
+
+                for ( x = txa ; x < txb ; x++ )
+                {
+                    bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
+        else
+        {
+            for ( y = begy ; y < endy ; y++ )
+            {
+                xa = xa + delta1;
+                xb = xb + delta3;
+                txb = MAX(0, xb);
+                txa = MIN(MAP_SIZE - 1, xa);
+
+                rac = sqrt(dist - SQR(y - memy));
+
+                txb = MAX(txb, memx - rac);
+                txa = MIN(txa, memx + rac);
+
+                for ( x = txb ; x < txa ; x++ )
+                {
+                    bm2_plot_point_ex(bigmap, id, x, y, cr, cg, cb);
+                }
+            }
+        }
     }
 }
 
 
 static void bm2_plot_cone(guchar *bigmap, guchar id,
-			 float x1, float y1, float x2, float y2, 
-			 float angle, guchar r, guchar g, guchar b)
+                          float x1, float y1, float x2, float y2,
+                          float angle, guchar r, guchar g, guchar b)
 {
-  float cs, sn, csi;
-  float x, y, xc, xd, yc, yd;
-  gboolean call_sub = FALSE;
-
-  x = x2 - x1;
-  y = y2 - y1;
-  if (angle > M_PI_2)
-    {
-      call_sub = TRUE;
-      angle /= 2;
-    }
-  cs = cos(angle / 2);
-  sn = sin(angle / 2);
-  xc = bm2_rotate_x(x, y, cs, sn);
-  xd = bm2_rotate_x(x, y, cs, -sn);
-  yc = bm2_rotate_y(x, y, cs, sn);
-  yd = bm2_rotate_y(x, y, cs, -sn);
-  if (call_sub)
-    {
-      bm2_plot_cone(bigmap, id, x1, y1, xc + x1, yc + y1, angle, r, g, b);
-      bm2_plot_cone(bigmap, id, x1, y1, xd + x1, yd + y1, angle, r, g, b);
-      return;
-    }
-  csi = 1 / cs;
-  xc = xc * csi + x1;
-  xd = xd * csi + x1;
-  yc = yc * csi + y1;
-  yd = yd * csi + y1;
-  bm2_plot_triangle(bigmap, id, x1, y1, xc, yc, xd, yd, 
-		   bm2_distance(x1, y1, x2, y2), r, g, b);
+    float cs, sn, csi;
+    float x, y, xc, xd, yc, yd;
+    bool call_sub = FALSE;
+
+    x = x2 - x1;
+    y = y2 - y1;
+    if ( angle > M_PI_2 )
+    {
+        call_sub = TRUE;
+        angle /= 2;
+    }
+    cs = cos(angle / 2);
+    sn = sin(angle / 2);
+    xc = bm2_rotate_x(x, y, cs, sn);
+    xd = bm2_rotate_x(x, y, cs, -sn);
+    yc = bm2_rotate_y(x, y, cs, sn);
+    yd = bm2_rotate_y(x, y, cs, -sn);
+    if ( call_sub )
+    {
+        bm2_plot_cone(bigmap, id, x1, y1, xc + x1, yc + y1, angle, r, g, b);
+        bm2_plot_cone(bigmap, id, x1, y1, xd + x1, yd + y1, angle, r, g, b);
+        return;
+    }
+    csi = 1 / cs;
+    xc = xc * csi + x1;
+    xd = xd * csi + x1;
+    yc = yc * csi + y1;
+    yd = yd * csi + y1;
+    bm2_plot_triangle(bigmap, id, x1, y1, xc, yc, xd, yd,
+                      bm2_distance(x1, y1, x2, y2), r, g, b);
 }
 
-static void bm2_plot_object(const conf_t *conf, const obj_t *obj, 
-			   guchar *bigmap, const guchar *colors)
+static void bm2_plot_object(const conf_t *conf, const obj_t *obj,
+                            guchar *bigmap, const guchar *colors)
 {
-  int x, y;
+    int x, y;
 
-  x = obj->posx * conf->big_zoom - conf->big_ofs_x;
-  y = obj->posy * conf->big_zoom - conf->big_ofs_y;
-  switch (obj->type)
+    x = obj->posx * conf->big_zoom - conf->big_ofs_x;
+    y = obj->posy * conf->big_zoom - conf->big_ofs_y;
+    switch ( obj->type )
     {
     case obj_akx :
-      bm2_plot_point(bigmap, x+2, y, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x-2, y, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x, y+2, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x, y-2, colors[2], colors[1], 
-		     colors[0]);
-
-      bm2_plot_point(bigmap, x+1, y+1, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x-1, y+1, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x+1, y-1, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x-1, y-1, colors[2], colors[1], 
-		     colors[0]);
+        bm2_plot_point(bigmap, x + 2, y, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x - 2, y, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x, y + 2, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x, y - 2, colors[2], colors[1],
+                       colors[0]);
+
+        bm2_plot_point(bigmap, x + 1, y + 1, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x - 1, y + 1, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x + 1, y - 1, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x - 1, y - 1, colors[2], colors[1],
+                       colors[0]);
     case obj_r4d2 :
-      bm2_plot_point(bigmap, x+1, y, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x, y+1, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x, y, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x-1, y, colors[2], colors[1], 
-		     colors[0]);
-      bm2_plot_point(bigmap, x, y-1, colors[2], colors[1], 
-		     colors[0]);
-      break;
+        bm2_plot_point(bigmap, x + 1, y, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x, y + 1, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x, y, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x - 1, y, colors[2], colors[1],
+                       colors[0]);
+        bm2_plot_point(bigmap, x, y - 1, colors[2], colors[1],
+                       colors[0]);
+        break;
     };
 }
 
-static void bm2_plot_akx_r4d2(const conf_t *conf, const obj_t *obj, 
-			      guchar *bigmap)
+static void bm2_plot_akx_r4d2(const conf_t *conf, const obj_t *obj,
+                              guchar *bigmap)
 {
-  int tid;
-
-  tid = obj->team_id;
-  if (tid > conf->map->nb_players)
-    tid = 0;
-  if ((tid == 0) && obj->type == obj_r4d2)
-    return;
-  bm2_plot_object(conf, obj, bigmap, conf->map->players[tid]->colors);
+    int tid;
+
+    tid = obj->team_id;
+    if ( tid > conf->map->nb_players )
+    {
+        tid = 0;
+    }
+    if (( tid == 0 ) && obj->type == obj_r4d2 )
+    {
+        return;
+    }
+    bm2_plot_object(conf, obj, bigmap, conf->map->players[tid]->colors);
 }
 
 static void bm2_plot_pulse(guchar *bigmap, const conf_t *conf,
-			  const obj_t *obj, guchar *colors)
+                           const obj_t *obj, guchar *colors)
 {
-  int	x, y, x2, y2, id;
-
-  id = obj->team_id;
-  x = obj->posx * conf->big_zoom - conf->big_ofs_x;
-  y = obj->posy * conf->big_zoom - conf->big_ofs_y;
-  x2 = obj->tx * conf->big_zoom - conf->big_ofs_x;
-  y2 = obj->ty * conf->big_zoom - conf->big_ofs_y;
-  
-  bm2_plot_cone(bigmap, (guchar)obj->id+1, x, y, x2, y2, 
-	       obj->angle,
-	       conf->map->players[id]->colors[2] / DIVID_PULSE_MINI, 
-	       conf->map->players[id]->colors[1] / DIVID_PULSE_MINI,
-	       conf->map->players[id]->colors[0] / DIVID_PULSE_MINI);
+    int x, y, x2, y2, id;
+
+    id = obj->team_id;
+    x = obj->posx * conf->big_zoom - conf->big_ofs_x;
+    y = obj->posy * conf->big_zoom - conf->big_ofs_y;
+    x2 = obj->tx * conf->big_zoom - conf->big_ofs_x;
+    y2 = obj->ty * conf->big_zoom - conf->big_ofs_y;
+
+    bm2_plot_cone(bigmap, (guchar) obj->id + 1, x, y, x2, y2,
+                  obj->angle,
+                  conf->map->players[id]->colors[2] / DIVID_PULSE_MINI,
+                  conf->map->players[id]->colors[1] / DIVID_PULSE_MINI,
+                  conf->map->players[id]->colors[0] / DIVID_PULSE_MINI);
 }
 
-static void bm2_plot_link(guchar *bigmap, const conf_t *conf, 
-			 const obj_t *obj, guchar *colors)
+static void bm2_plot_link(guchar *bigmap, const conf_t *conf,
+                          const obj_t *obj, guchar *colors)
 {
-  int x, y, x2, y2;
+    int x, y, x2, y2;
 
-  x = obj->posx * conf->big_zoom - conf->big_ofs_x;
-  y = obj->posy * conf->big_zoom - conf->big_ofs_y;
-  x2 = conf->map->objects[obj->target]->posx * 
-    conf->big_zoom - conf->big_ofs_x;
-  y2 = conf->map->objects[obj->target]->posy * 
-    conf->big_zoom - conf->big_ofs_y;
+    x = obj->posx * conf->big_zoom - conf->big_ofs_x;
+    y = obj->posy * conf->big_zoom - conf->big_ofs_y;
+    x2 = conf->map->objects[obj->target]->posx *
+         conf->big_zoom - conf->big_ofs_x;
+    y2 = conf->map->objects[obj->target]->posy *
+         conf->big_zoom - conf->big_ofs_y;
 
-  bm2_plot_line(bigmap, x, y, x2, y2, colors[2], colors[1], colors[0]);
+    bm2_plot_line(bigmap, x, y, x2, y2, colors[2], colors[1], colors[0]);
 }
 
-static void bm2_plot_pulse_link(const conf_t *conf, const obj_t *obj, 
-			       guchar *bigmap)
+static void bm2_plot_pulse_link(const conf_t *conf, const obj_t *obj,
+                                guchar *bigmap)
 {
-  int tid;
-
-  tid = obj->team_id;
-  if (tid > conf->map->nb_players)
-    tid = 0;
-  /* affichage pulse */
-  if (obj->action == act_akx_pulse)
-    bm2_plot_pulse(bigmap, conf, obj, conf->map->players[tid]->colors);
-  
-  /* affichage link */
-  if (obj->action == act_akx_link)
-    bm2_plot_link(bigmap, conf, obj, conf->map->players[tid]->colors);
+    int tid;
+
+    tid = obj->team_id;
+    if ( tid > conf->map->nb_players )
+    {
+        tid = 0;
+    }
+    /* affichage pulse */
+    if ( obj->action == act_akx_pulse )
+    {
+        bm2_plot_pulse(bigmap, conf, obj, conf->map->players[tid]->colors);
+    }
+
+    /* affichage link */
+    if ( obj->action == act_akx_link )
+    {
+        bm2_plot_link(bigmap, conf, obj, conf->map->players[tid]->colors);
+    }
 }
 
-guchar *gen_bigmap2(conf_t *conf, gboolean force)
+guchar *gen_bigmap2(conf_t *conf, bool force)
 {
-  int			cpt;
-  obj_t			*obj;
+    int cpt;
+    obj_t *obj;
 
-  if (conf->screen == NULL)
+    if ( conf->screen == NULL )
     {
-      conf->screen = g_malloc(4 * SQR(MAP_SIZE));
-      bzero(conf->screen, 4 * SQR(MAP_SIZE));
+        conf->screen = g_malloc(4 * SQR(MAP_SIZE));
+        bzero(conf->screen, 4 * SQR(MAP_SIZE));
     }
-  if (!force)
-    return conf->screen;
-  if (conf->map == NULL)
-    return conf->screen;
-  bzero(conf->screen, 4 * SQR(MAP_SIZE));
+    if ( !force )
+    {
+        return conf->screen;
+    }
+    if ( conf->map == NULL )
+    {
+        return conf->screen;
+    }
+    bzero(conf->screen, 4 * SQR(MAP_SIZE));
 
-  if (conf->big_pulse)
-    for (cpt = 0; cpt < conf->map->nb_objects; cpt++)
-      {
-	obj = conf->map->objects[cpt];
-	if (obj->type == obj_akx)
-	  bm2_plot_pulse_link(conf, obj, conf->screen); 
-      }
+    if ( conf->big_pulse )
+    {
+        for ( cpt = 0 ; cpt < conf->map->nb_objects ; cpt++ )
+        {
+            obj = conf->map->objects[cpt];
+            if ( obj->type == obj_akx )
+            {
+                bm2_plot_pulse_link(conf, obj, conf->screen);
+            }
+        }
+    }
 
-  for (cpt = 0; cpt < conf->map->nb_objects; cpt++)
+    for ( cpt = 0 ; cpt < conf->map->nb_objects ; cpt++ )
     {
-      obj = conf->map->objects[cpt];
-      bm2_plot_akx_r4d2(conf, obj, conf->screen);
+        obj = conf->map->objects[cpt];
+        bm2_plot_akx_r4d2(conf, obj, conf->screen);
     }
-  return conf->screen;
+    return conf->screen;
 }

+ 3 - 5
gclient/gen_minimap.c

@@ -1,5 +1,3 @@
-/* $Id: gen_minimap.c,v 1.23 2001/04/29 15:41:05 glop Exp $ */
-
 #include "client.h"
 
 #define OFFSET(X, Y)    (((X) + (Y) * MINI_MAP_SIZE) * 4)
@@ -211,7 +209,7 @@ static void mm_plot_triangle(guchar *minimap, guchar id, guchar sat,
   else
     delta3 = 0;
   
-  /* PremiŠre partie du triangle ( tracage des section horizontale) */
+  /* Premi�re partie du triangle ( tracage des section horizontale) */
 
   xa = x1;
   xb = x1;
@@ -272,7 +270,7 @@ static void mm_plot_cone(guchar *minimap, guchar id, guchar sat,
 {
   float cs, sn, csi;
   float x, y, xc, xd, yc, yd;
-  gboolean call_sub = FALSE;
+  bool call_sub = FALSE;
 
   x = x2 - x1;
   y = y2 - y1;
@@ -400,7 +398,7 @@ static void mm_plot_rectangle(guchar *minimap, const conf_t *conf)
     }
 }
 
-guchar *gen_minimap(const conf_t *conf, gboolean force)
+guchar *gen_minimap(const conf_t *conf, bool force)
 {
   static guchar		*minimap = NULL;
   int			cpt;

+ 27 - 27
gclient/gtk.c

@@ -1,38 +1,38 @@
-/* $Id: gtk.c,v 1.7 2001/04/14 20:01:15 kilobug Exp $ */
-
 #include "client.h"
 
 GtkWidget *create_picture(const char *filename, conf_t *conf)
 {
-  GdkPixmap *pm;
-  GdkBitmap *mask;
-  GtkStyle *style;
-  GtkWidget *wid;
-  char *name;
+    GdkPixmap *pm;
+    GdkBitmap *mask;
+    GtkStyle *style;
+    GtkWidget *wid;
+    char *name;
 
-  name = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S, 
-		     filename, NULL);
-  style = gtk_widget_get_style(conf->window);
-  pm = gdk_pixmap_create_from_xpm(conf->window->window, &mask, 
-				  &style->bg[GTK_STATE_NORMAL],
-				  name);
-  g_free(name);
-  wid = gtk_pixmap_new(pm, mask);
-  gtk_widget_show(wid);
-  return wid;
+    name = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S,
+                       filename, NULL);
+    style = gtk_widget_get_style(conf->window);
+    pm = gdk_pixmap_create_from_xpm(conf->window->window, &mask,
+                                    &style->bg[GTK_STATE_NORMAL],
+                                    name);
+    g_free(name);
+    wid = gtk_pixmap_new(pm, mask);
+    gtk_widget_show(wid);
+    return wid;
 }
 
-GtkWidget *create_xpm_button(const char *filename, GtkSignalFunc callback, 
-			     conf_t *conf)
+GtkWidget *create_xpm_button(const char *filename, GtkSignalFunc callback,
+                             conf_t *conf)
 {
-  GtkWidget *pic, *wid;
+    GtkWidget *pic, *wid;
 
-  pic = create_picture(filename, conf);
-  wid = gtk_button_new();
-  gtk_container_add(GTK_CONTAINER(wid), pic);  
-  gtk_widget_show(wid);
-  if (callback != NULL)
-    gtk_signal_connect(GTK_OBJECT(wid), "pressed", callback, conf);
-  return wid;
+    pic = create_picture(filename, conf);
+    wid = gtk_button_new();
+    gtk_container_add(GTK_CONTAINER(wid), pic);
+    gtk_widget_show(wid);
+    if ( callback != NULL )
+    {
+        gtk_signal_connect(GTK_OBJECT(wid), "pressed", callback, conf);
+    }
+    return wid;
 }
 

+ 106 - 80
gclient/include/client.h

@@ -1,112 +1,121 @@
-/* $Id: client.h,v 1.43 2001/04/29 22:24:37 kilobug Exp $ */
 #ifndef __PROLO_CLIENT_H__
 #define __PROLO_CLIENT_H__
 
-#define MINI_MAP_SIZE		200
-#define MAP_SIZE		500
-#define WANT_PROTOCOL_VERSION	1
-#define	DIVID_PULSE_MINI	1/* 6 */
-#define	PULSE_SAT		0xFF/*7F*/
-#define	SPRITE_COLOR_DIV	4
+#define MINI_MAP_SIZE 200
+#define MAP_SIZE 500
+#define WANT_PROTOCOL_VERSION 1
+#define DIVID_PULSE_MINI 1/* 6 */
+#define PULSE_SAT 0xFF/*7F*/
+#define SPRITE_COLOR_DIV 4
 
 #include "../netlib/net.h"
 #include "../general.h"
 #include "../gtkutil/gtkutil.h"
 
-typedef enum _obj_type_t { obj_r4d2 = 0, obj_akx = 1 } obj_type_t;
-typedef enum _obj_act_t { act_akx_move = 0, act_akx_pulse = 1, 
-			  act_akx_link = 2 } obj_act_t;
+typedef enum _obj_type_t
+{
+    obj_r4d2 = 0, obj_akx = 1
+} obj_type_t;
+
+typedef enum _obj_act_t
+{
+    act_akx_move = 0, act_akx_pulse = 1,
+    act_akx_link = 2
+} obj_act_t;
 
-#define	SQR(X) ((X) * (X))
+#define    SQR(X) ((X) * (X))
 
-typedef struct	_image_t
+typedef struct _image_t
 {
-  int		sx;
-  int		sy;
-  guchar	*data;/* en 32bits R8 G8 B8 A8*/
-  char		*name;
-}		image_t;
+    int sx;
+    int sy;
+    guchar *data;/* en 32bits R8 G8 B8 A8*/
+    char *name;
+} image_t;
 
 typedef struct _player_t
 {
-  int id;
-  char *name;
-  float score;
-  guchar colors[3];
-  image_t *r4d2;
-  image_t *akx;
-  GdkColor *gdkcol;
+    int id;
+    char *name;
+    float score;
+    guchar colors[3];
+    image_t *r4d2;
+    image_t *akx;
+    GdkColor *gdkcol;
 } player_t;
-  
+
 
 typedef struct _obj_t
 {
-  int id;
-  obj_type_t type;
-  float posx, posy;
-  int team_id;
-  gboolean changed;
-
-  obj_act_t action;
-  int target;
-  float tx, ty;
-  float angle;
+    int id;
+    obj_type_t type;
+    float posx, posy;
+    int team_id;
+    bool changed;
+
+    obj_act_t action;
+    int target;
+    float tx, ty;
+    float angle;
 } obj_t;
 
 typedef struct _map_t
 {
-  int nb_players;
-  int nb_turns, turn_num;
-  int nb_objects, nb_akx, nb_r4d2;
-  float sizex, sizey;
-  player_t **players;
-  obj_t **objects;
-  char *sand_file;
-  image_t *background;
+    int nb_players;
+    int nb_turns, turn_num;
+    int nb_objects, nb_akx, nb_r4d2;
+    float sizex, sizey;
+    player_t **players;
+    obj_t **objects;
+    char *sand_file;
+    image_t *background;
 } map_t;
 
 typedef struct _turn_t
 {
-  int nbt;
-  int spd;
-  int gtkto;
-  int st_turns;
-  enum { tt_pause, tt_skip, tt_fwd } mode;
+    int nbt;
+    int spd;
+    int gtkto;
+    int st_turns;
+    enum
+    {
+        tt_pause, tt_skip, tt_fwd
+    } mode;
 } turn_t;
 
 typedef struct _stat_t
 {
-  GtkWidget *pl, *stat, *r4d2, *akx, *menu;
-  gboolean on;
+    GtkWidget *pl, *stat, *r4d2, *akx, *menu;
+    bool on;
 } stat_t;
 
 typedef struct _conf_t
 {
-  int socket;
-  FILE *file;
-  gboolean debug;
-  const char *host;
-  int port;
-  GtkWidget *status, *window, *conf;
-  GtkWidget *main, *mini, *pl, *turn_bar;
-  GtkTooltips *tooltips;
-  map_t *map;
-  int gdk_io_id;
-  gboolean ready, connected, terminated;
-  turn_t turn;
-  stat_t stat;
-
-  int big_ofs_x, big_ofs_y;
-  int mini_center_x, mini_center_y;
-  float big_zoom, log_big_zoom;
-  gboolean big_radar;
-  gboolean big_pulse;
-  guchar *screen;
-  guchar *convtb;
-
-  image_t *r4d2;
-  image_t *akx;
-  image_t *background;
+    int socket;
+    FILE *file;
+    bool debug;
+    const char *host;
+    int port;
+    GtkWidget *status, *window, *conf;
+    GtkWidget *main, *mini, *pl, *turn_bar;
+    GtkTooltips *tooltips;
+    map_t *map;
+    int gdk_io_id;
+    bool ready, connected, terminated;
+    turn_t turn;
+    stat_t stat;
+
+    int big_ofs_x, big_ofs_y;
+    int mini_center_x, mini_center_y;
+    float big_zoom, log_big_zoom;
+    bool big_radar;
+    bool big_pulse;
+    guchar *screen;
+    guchar *convtb;
+
+    image_t *r4d2;
+    image_t *akx;
+    image_t *background;
 } conf_t;
 
 extern conf_t *gl_config;
@@ -115,36 +124,53 @@ extern conf_t *gl_config;
 ** Init
 */
 conf_t *init(int argc, char **argv);
+
 void create_gtk_stuff(conf_t *conf);
+
 void byebye(GtkWidget *widget, conf_t *conf);
+
 void network_error(net_type_t get, net_type_t wanted, void *data);
 
 void do_connect(conf_t *conf);
+
 gint idle_connect(void *conf);  /* Always returns FALSE for gtk_idle */
 void callback_connect(GtkWidget *widget, void *conf);
+
 void send_goodbye(conf_t *conf);
 
 void load_map(conf_t *conf);
+
 void destroy_map(conf_t *conf);
+
 void get_object_param(int fd, obj_t *obj, conf_t *conf);
 
 void allow_new_turn(conf_t *conf);
+
 void close_socket(conf_t *conf);
+
 void protocol_error(conf_t *conf, const char *msg);
-gboolean tb_new_turn(void *conf);
 
-guchar *gen_minimap(const conf_t *conf, gboolean force);
-guchar *gen_bigmap(conf_t *conf, gboolean force);
-guchar *gen_bigmap2(conf_t *conf, gboolean force);
+bool tb_new_turn(void *conf);
+
+guchar *gen_minimap(const conf_t *conf, bool force);
+
+guchar *gen_bigmap(conf_t *conf, bool force);
+
+guchar *gen_bigmap2(conf_t *conf, bool force);
+
 void gen_colors(int id, int nbr, player_t *play);
+
 void scroll_bigmap(conf_t *conf, float x, float y);
 
 image_t *load_picture(const char *filename, const char *mask);
+
 void destroy_picture(image_t *pic);
+
 image_t *tint_picture(const image_t *src, guchar *col);
+
 image_t *dup_picture(const image_t *src);
 
-int	fast_sqrt(unsigned int a);
+int fast_sqrt(unsigned int a);
 
 #include "client_gtk.h"
 

+ 17 - 2
gclient/include/client_gtk.h

@@ -5,14 +5,17 @@
 ** General GTK wrappers
 */
 void update_map_callback(void *conf, gint src, GdkInputCondition cond);
+
 GtkWidget *create_picture(const char *filename, conf_t *conf);
-GtkWidget *create_xpm_button(const char *filename, GtkSignalFunc callback, 
-			     conf_t *conf);
+
+GtkWidget *create_xpm_button(const char *filename, GtkSignalFunc callback,
+                             conf_t *conf);
 
 /*
 ** Statusbar
 */
 void set_status(const conf_t *conf, const char *msg);
+
 GtkWidget *create_statusbar(conf_t *conf);
 
 /*
@@ -24,32 +27,44 @@ GtkWidget *create_menubar(conf_t *conf);
 ** Stats
 */
 void create_stats(conf_t *conf);
+
 void stats_refresh(conf_t *conf);
+
 void stats_make(conf_t *conf);
+
 void pl_make_color(GdkColor *col, int r, int g, int b);
 
 /*
 ** Toolbar
 */
 GtkWidget *create_toolbar(conf_t *conf);
+
 void player_list_refresh(const conf_t *conf);
+
 void player_list_make(conf_t *conf);
+
 GtkWidget *create_players_list(conf_t *conf);
+
 void tb_pause(GtkWidget *wid, conf_t *conf);
+
 void tb_play(GtkWidget *wid, conf_t *conf);
+
 void tb_step(GtkWidget *wid, conf_t *conf);
+
 void tb_ffwd(GtkWidget *wid, conf_t *conf);
 
 /*
 ** Gamearea
 */
 GtkWidget *create_game_area(conf_t *conf);
+
 void gamearea_refresh(GtkWidget *w, conf_t *conf);
 
 /*
 ** Minimap
 */
 GtkWidget *create_mini_map(conf_t *conf);
+
 void minimap_refresh(GtkWidget *w, const conf_t *conf);
 
 #endif

+ 90 - 86
gclient/init.c

@@ -1,5 +1,3 @@
-/* $Id: init.c,v 1.26 2001/04/29 22:24:37 kilobug Exp $ */
-
 #include "client.h"
 
 #define DEFAULT_PORT 4242
@@ -9,127 +7,133 @@ conf_t *gl_config = NULL;
 
 static void clean()
 {
-  send_goodbye(gl_config);
+    send_goodbye(gl_config);
 }
 
 static void clean_exit()
 {
-  clean();
-  exit(1);
+    clean();
+    exit(1);
 }
 
 static void help(const char *name)
 {
-  printf("syntaxe: %s [-d] [-h machine] [-p port]\n", name);
-  exit(1);
+    printf("syntaxe: %s [-d] [-h machine] [-p port]\n", name);
+    exit(1);
 }
 
 static const char *get_arg(int argc, char **argv, int *i)
 {
-  if (*i == argc - 1)
+    if ( *i == argc - 1 )
     {
-      printf("%s requiert un argument.\n", argv[*i]);
-      exit(1);
+        printf("%s requiert un argument.\n", argv[*i]);
+        exit(1);
     }
-  return (argv[++(*i)]);
+    return ( argv[++( *i )] );
 }
 
 static void sigusr2()
 {
-  gl_config->terminated = TRUE;
-  if (gl_config->ready)
-    allow_new_turn(gl_config);
+    gl_config->terminated = TRUE;
+    if ( gl_config->ready )
+    {
+        allow_new_turn(gl_config);
+    }
 }
 
 static guchar *gen_convtb()
 {
-  guchar *res;
-  int org, add;
-  double f;
+    guchar *res;
+    int org, add;
+    double f;
 
-  res = g_malloc(256 * 256 * sizeof(*res));
-  for (org = 0; org < 256; org++)
-    for (add = 0; add < 256; add++)
-      {
-	/*	f = ((double) org / 256);
-		f = (0.2 + 0.8 * SQR(f)) * add / 1.3;*/
-	f = add * 0.3;
-	res[org + add * 256] = MIN(org + f, 255);
-      }
-  return res;
+    res = g_malloc(256 * 256 * sizeof(*res));
+    for ( org = 0 ; org < 256 ; org++ )
+    {
+        for ( add = 0 ; add < 256 ; add++ )
+        {
+            /*	f = ((double) org / 256);
+                f = (0.2 + 0.8 * SQR(f)) * add / 1.3;*/
+            f = add * 0.3;
+            res[org + add * 256] = MIN(org + f, 255);
+        }
+    }
+    return res;
 }
 
 conf_t *init(int argc, char **argv)
 {
-  conf_t *res;
-  int i;
+    conf_t *res;
+    int i;
 
-  gtk_set_locale();
-  gtk_init(&argc, &argv);
-  gdk_set_use_xshm(TRUE);
-  gdk_rgb_init();
+    gtk_set_locale();
+    gtk_init(&argc, &argv);
+    gdk_set_use_xshm(TRUE);
+    gdk_rgb_init();
 
-  res = g_malloc(sizeof(*res));
-  res->screen = NULL;
-  res->debug = FALSE;
-  res->socket = -1;
-  res->host = DEFAULT_HOST;
-  res->port = DEFAULT_PORT;
-  res->gdk_io_id = -1;
-  res->map = NULL;
-  res->convtb = gen_convtb();
-  res->turn.mode = tt_pause;
-  res->turn.nbt = 10;
-  res->turn.spd = 50;
-  res->connected = res->ready = FALSE;
-  res->window = res->status = res->mini = res->main = res->conf = NULL;
-  res->stat.r4d2 = res->stat.akx = res->stat.pl = res->stat.stat = NULL;
-  res->stat.menu = NULL;
-  res->stat.on = FALSE;
-  for (i = 1; i < argc; i++)
+    res = g_malloc(sizeof(*res));
+    res->screen = NULL;
+    res->debug = FALSE;
+    res->socket = -1;
+    res->host = DEFAULT_HOST;
+    res->port = DEFAULT_PORT;
+    res->gdk_io_id = -1;
+    res->map = NULL;
+    res->convtb = gen_convtb();
+    res->turn.mode = tt_pause;
+    res->turn.nbt = 10;
+    res->turn.spd = 50;
+    res->connected = res->ready = FALSE;
+    res->window = res->status = res->mini = res->main = res->conf = NULL;
+    res->stat.r4d2 = res->stat.akx = res->stat.pl = res->stat.stat = NULL;
+    res->stat.menu = NULL;
+    res->stat.on = FALSE;
+    for ( i = 1 ; i < argc ; i++ )
     {
-      if (argv[i][0] != '-')
-	help(argv[0]);
-      switch (argv[i][1])
-	{
-	case 'd':
-	  res->debug = TRUE;
-	  break;
-	case 'h':
-	  res->host = get_arg(argc, argv, &i);
-	  break;
-	case 'p':
-	  res->port = atoi(get_arg(argc, argv, &i));
-	  break;
-	default:
-	  help(argv[0]);
-	}
+        if ( argv[i][0] != '-' )
+        {
+            help(argv[0]);
+        }
+        switch ( argv[i][1] )
+        {
+        case 'd':
+            res->debug = TRUE;
+            break;
+        case 'h':
+            res->host = get_arg(argc, argv, &i);
+            break;
+        case 'p':
+            res->port = atoi(get_arg(argc, argv, &i));
+            break;
+        default:
+            help(argv[0]);
+        }
     }
-  res->host = g_strdup(res->host);
-  res->background = load_picture("sand.gif", NULL);
-  res->akx = load_picture("akx.xpm", "akx_mask.xpm");
-  res->r4d2 = load_picture("r4d2.xpm", "r4d2_mask.xpm");
-  res->big_ofs_x = res->big_ofs_y = 0;
-  res->mini_center_x = res->mini_center_y = 0;
-  res->big_zoom = 50.0;
-  res->log_big_zoom = 4;
-  res->big_radar = FALSE;
-  res->big_pulse = TRUE;
-  net_set_error_handler(network_error, res);
-  gl_config = res;
-  atexit(clean);
-  signal(SIGINT, clean_exit);
-  signal(SIGUSR2, sigusr2);
-  return res;
+    res->host = g_strdup(res->host);
+    res->background = load_picture("sand.gif", NULL);
+    res->akx = load_picture("akx.xpm", "akx_mask.xpm");
+    res->r4d2 = load_picture("r4d2.xpm", "r4d2_mask.xpm");
+    res->big_ofs_x = res->big_ofs_y = 0;
+    res->mini_center_x = res->mini_center_y = 0;
+    res->big_zoom = 50.0;
+    res->log_big_zoom = 4;
+    res->big_radar = FALSE;
+    res->big_pulse = TRUE;
+    net_set_error_handler(network_error, res);
+    gl_config = res;
+    atexit(clean);
+    signal(SIGINT, clean_exit);
+    signal(SIGUSR2, sigusr2);
+    return res;
 }
 
 gint idle_connect(void *conf)
 {
-  do_connect(conf);
-  return FALSE;
+    do_connect(conf);
+    return FALSE;
 }
 
 void callback_connect(GtkWidget *widget, void *conf)
 {
-  do_connect(conf);
+    do_connect(conf);
 }

+ 139 - 129
gclient/load_map.c

@@ -1,176 +1,186 @@
-/* $Id: load_map.c,v 1.19 2001/04/29 17:35:16 kilobug Exp $ */
-
 #include "client.h"
 
 void get_object_param(int fd, obj_t *obj, conf_t *conf)
 {
-  obj->posx = net_get_float(conf->socket);
-  obj->posy = net_get_float(conf->socket);
-  obj->team_id = net_get_int(conf->socket);
-  if (obj->type == obj_akx)
+    obj->posx = net_get_float(conf->socket);
+    obj->posy = net_get_float(conf->socket);
+    obj->team_id = net_get_int(conf->socket);
+    if ( obj->type == obj_akx )
     {
-      obj->action = net_get_int(fd);
-      switch (obj->action)
-	{
-	case act_akx_move:
-	  break;
-	case act_akx_pulse:
-	  obj->angle = net_get_float(fd);
-	  obj->tx = net_get_float(fd);
-	  obj->ty = net_get_float(fd);
-	  break;
-	case act_akx_link:
-	  obj->target = net_get_int(fd);
-	  break;
-	default:
-	  protocol_error(conf, "invalid action");
-	  return;
-	}
-    } 
+        obj->action = net_get_int(fd);
+        switch ( obj->action )
+        {
+        case act_akx_move:
+            break;
+        case act_akx_pulse:
+            obj->angle = net_get_float(fd);
+            obj->tx = net_get_float(fd);
+            obj->ty = net_get_float(fd);
+            break;
+        case act_akx_link:
+            obj->target = net_get_int(fd);
+            break;
+        default:
+            protocol_error(conf, "invalid action");
+            return;
+        }
+    }
 }
 
 static player_t *get_player(conf_t *conf)
 {
-  player_t *res;
+    player_t *res;
 
-  if (!net_chk_string(conf->socket, "PLR"))
+    if ( !net_chk_string(conf->socket, "PLR"))
     {
-      protocol_error(conf, "PLR exepected");
-      return NULL;      
+        protocol_error(conf, "PLR exepected");
+        return NULL;
     }
-  res = g_malloc(sizeof(*res));
-  res->id = net_get_int(conf->socket);
-  if ((res->id > conf->map->nb_players) || (res->id < 1))
+    res = g_malloc(sizeof(*res));
+    res->id = net_get_int(conf->socket);
+    if (( res->id > conf->map->nb_players ) || ( res->id < 1 ))
     {
-      protocol_error(conf, "player id invalid");
-      g_free(res);
-      return NULL;      
-    } 
-  res->name = net_get_string(conf->socket);
-  res->score = net_get_float(conf->socket);
-  gen_colors(res->id, conf->map->nb_players + 1, res);  
-  res->akx = tint_picture(conf->akx, res->colors);
-  res->r4d2 = tint_picture(conf->r4d2, res->colors);
-  return res;
+        protocol_error(conf, "player id invalid");
+        g_free(res);
+        return NULL;
+    }
+    res->name = net_get_string(conf->socket);
+    res->score = net_get_float(conf->socket);
+    gen_colors(res->id, conf->map->nb_players + 1, res);
+    res->akx = tint_picture(conf->akx, res->colors);
+    res->r4d2 = tint_picture(conf->r4d2, res->colors);
+    return res;
 }
 
-static gboolean get_players(conf_t *conf)
-{  
-  int i;
-  player_t *player;
+static bool get_players(conf_t *conf)
+{
+    int i;
+    player_t *player;
 
-  conf->map->players = g_malloc(sizeof(*(conf->map->players)) * 
-				(conf->map->nb_players + 1));
-  for (i = 0; i < conf->map->nb_players; i++)
-    conf->map->players[i + 1] = NULL;
-  for (i = 0; i < conf->map->nb_players; i++)
+    conf->map->players = g_malloc(sizeof(*( conf->map->players )) *
+                                  ( conf->map->nb_players + 1 ));
+    for ( i = 0 ; i < conf->map->nb_players ; i++ )
+    {
+        conf->map->players[i + 1] = NULL;
+    }
+    for ( i = 0 ; i < conf->map->nb_players ; i++ )
     {
-      player = get_player(conf);
-      if (player == NULL)
-	return FALSE;
-      conf->map->players[player->id] = player;
+        player = get_player(conf);
+        if ( player == NULL )
+        {
+            return FALSE;
+        }
+        conf->map->players[player->id] = player;
     }
-  net_send_ack(conf->file);
-  conf->map->players[0] = g_malloc(sizeof (*conf->map->players[0]));
-  conf->map->players[0]->id = 0;
-  conf->map->players[0]->name = "Sauvage";
-  conf->map->players[0]->score = 0.0;
-  conf->map->players[0]->akx = load_picture("akx_0.xpm", 
-					    "akx_0_mask.xpm");
-  conf->map->players[0]->r4d2 = load_picture("r4d2_0.xpm", 
-					     "r4d2_0_mask.xpm");
-  gen_colors(0, conf->map->nb_players + 1, conf->map->players[0]);
-  player_list_make(conf);
-  stats_make(conf);
-  return TRUE;
+    net_send_ack(conf->file);
+    conf->map->players[0] = g_malloc(sizeof(*conf->map->players[0]));
+    conf->map->players[0]->id = 0;
+    conf->map->players[0]->name = "Sauvage";
+    conf->map->players[0]->score = 0.0;
+    conf->map->players[0]->akx = load_picture("akx_0.xpm",
+                                              "akx_0_mask.xpm");
+    conf->map->players[0]->r4d2 = load_picture("r4d2_0.xpm",
+                                               "r4d2_0_mask.xpm");
+    gen_colors(0, conf->map->nb_players + 1, conf->map->players[0]);
+    player_list_make(conf);
+    stats_make(conf);
+    return TRUE;
 }
 
 static obj_t *get_object(conf_t *conf)
 {
-  obj_t *res;
+    obj_t *res;
 
-  if (!net_chk_string(conf->socket, "OBJ"))
+    if ( !net_chk_string(conf->socket, "OBJ"))
     {
-      protocol_error(conf, "OBJ expected");
-      return NULL;      
+        protocol_error(conf, "OBJ expected");
+        return NULL;
     }
-  res = g_malloc(sizeof(*res));
-  res->changed = TRUE;
-  res->id = net_get_int(conf->socket);
-  if ((res->id >= conf->map->nb_objects) || (res->id < 0))
+    res = g_malloc(sizeof(*res));
+    res->changed = TRUE;
+    res->id = net_get_int(conf->socket);
+    if (( res->id >= conf->map->nb_objects ) || ( res->id < 0 ))
     {
-      protocol_error(conf, "object id invalid");
-      g_free(res);
-      return NULL;
+        protocol_error(conf, "object id invalid");
+        g_free(res);
+        return NULL;
     }
-  res->type = net_get_int(conf->socket);
-  if ((res->type != obj_r4d2) && (res->type != obj_akx))
+    res->type = net_get_int(conf->socket);
+    if (( res->type != obj_r4d2 ) && ( res->type != obj_akx ))
     {
-      protocol_error(conf, "object type invalid");
-      g_free(res);
-      return NULL;
+        protocol_error(conf, "object type invalid");
+        g_free(res);
+        return NULL;
     }
-  get_object_param(conf->socket, res, conf);
-  return res;
+    get_object_param(conf->socket, res, conf);
+    return res;
 }
 
-static gboolean get_objects(conf_t *conf)
+static bool get_objects(conf_t *conf)
 {
-  int i;
-  obj_t *obj;
+    int i;
+    obj_t *obj;
 
-  conf->map->objects = g_malloc(sizeof(*(conf->map->objects)) * 
-				conf->map->nb_objects);
-  for (i = 0; i < conf->map->nb_objects; i++)
-    conf->map->objects[i] = NULL;
-  for (i = 0; i < conf->map->nb_objects; i++)
+    conf->map->objects = g_malloc(sizeof(*( conf->map->objects )) *
+                                  conf->map->nb_objects);
+    for ( i = 0 ; i < conf->map->nb_objects ; i++ )
     {
-      obj = get_object(conf);
-      if (obj == NULL)
-	return FALSE;
-      conf->map->objects[obj->id] = obj;
+        conf->map->objects[i] = NULL;
     }
-  net_send_ack(conf->file);
-  return TRUE;
+    for ( i = 0 ; i < conf->map->nb_objects ; i++ )
+    {
+        obj = get_object(conf);
+        if ( obj == NULL )
+        {
+            return FALSE;
+        }
+        conf->map->objects[obj->id] = obj;
+    }
+    net_send_ack(conf->file);
+    return TRUE;
 }
 
 void load_map(conf_t *conf)
 {
-  map_t *map;
+    map_t *map;
 
-  conf->ready = FALSE;
-  destroy_map(conf);
+    conf->ready = FALSE;
+    destroy_map(conf);
 
-  map = g_malloc(sizeof(*map));
-  conf->map = map;
-  map->sizex = net_get_float(conf->socket);
-  map->sizey = net_get_float(conf->socket);
-  map->nb_turns = net_get_int(conf->socket);
-  map->turn_num = net_get_int(conf->socket);
-  map->nb_players = net_get_int(conf->socket);
-  map->nb_r4d2 = net_get_int(conf->socket);
-  map->nb_akx = net_get_int(conf->socket);
-  map->sand_file = net_get_string(conf->socket);
-  if (map->sand_file[0] == 0)
-    map->background = NULL;
-  else
-    map->background = load_picture(map->sand_file, NULL);
-  map->nb_objects = map->nb_r4d2 + map->nb_akx;
-  map->players = NULL;
-  map->objects = NULL;
-  net_send_ack(conf->file);
+    map = g_malloc(sizeof(*map));
+    conf->map = map;
+    map->sizex = net_get_float(conf->socket);
+    map->sizey = net_get_float(conf->socket);
+    map->nb_turns = net_get_int(conf->socket);
+    map->turn_num = net_get_int(conf->socket);
+    map->nb_players = net_get_int(conf->socket);
+    map->nb_r4d2 = net_get_int(conf->socket);
+    map->nb_akx = net_get_int(conf->socket);
+    map->sand_file = net_get_string(conf->socket);
+    if ( map->sand_file[0] == 0 )
+    {
+        map->background = NULL;
+    }
+    else
+    {
+        map->background = load_picture(map->sand_file, NULL);
+    }
+    map->nb_objects = map->nb_r4d2 + map->nb_akx;
+    map->players = NULL;
+    map->objects = NULL;
+    net_send_ack(conf->file);
 
-  if (!get_players(conf))
+    if ( !get_players(conf))
     {
-      destroy_map(conf);
-      return;
+        destroy_map(conf);
+        return;
     }
-  if (!get_objects(conf))
+    if ( !get_objects(conf))
     {
-      destroy_map(conf);
-      return;
+        destroy_map(conf);
+        return;
     }
-  conf->ready = TRUE;  
-  scroll_bigmap(conf, -4242, -4242);
-  stats_make(conf);
+    conf->ready = TRUE;
+    scroll_bigmap(conf, -4242, -4242);
+    stats_make(conf);
 }

+ 7 - 9
gclient/main.c

@@ -1,15 +1,13 @@
-/* $Id: main.c,v 1.6 2001/04/10 17:16:22 kilobug Exp $ */
-
 #include "client.h"
 
 int main(int argc, char **argv)
 {
-  conf_t *conf;
+    conf_t *conf;
 
-  conf = init(argc, argv);
-  create_gtk_stuff(conf);
-  gtk_idle_add(idle_connect, conf);
-  gtk_main();
-  gtk_exit(0);
-  return 0;
+    conf = init(argc, argv);
+    create_gtk_stuff(conf);
+    gtk_idle_add(idle_connect, conf);
+    gtk_main();
+    gtk_exit(0);
+    return 0;
 }

+ 60 - 62
gclient/mainbox.c

@@ -1,88 +1,86 @@
-/* $Id: mainbox.c,v 1.13 2001/04/29 22:33:21 kilobug Exp $ */
-
 #include "client.h"
 
 void byebye(GtkWidget *widget, conf_t *conf)
 {
-  if (conf->debug && conf->connected)
+    if ( conf->debug && conf->connected )
     {
-      conf->ready = TRUE;
-      conf->terminated = TRUE;
-      allow_new_turn(conf);      
+        conf->ready = TRUE;
+        conf->terminated = TRUE;
+        allow_new_turn(conf);
     }
-  gtk_main_quit();
+    gtk_main_quit();
 }
 
 static void create_mainbox(conf_t *conf)
 {
-  GtkWidget *table, *widget;
+    GtkWidget *table, *widget;
 
-  conf->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_default_size(GTK_WINDOW(conf->window), 
-			      MAP_SIZE + MINI_MAP_SIZE + 10,
-			      MAP_SIZE + 20);
-  gtk_signal_connect(GTK_OBJECT(conf->window), "destroy", 
-		     GTK_SIGNAL_FUNC(byebye), conf);
-  gtk_window_set_title(GTK_WINDOW(conf->window), "Finale Prologin 2001");
-  gtk_window_set_policy(GTK_WINDOW(conf->window), FALSE, FALSE, TRUE);
-  gtk_widget_show(conf->window);
+    conf->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_default_size(GTK_WINDOW(conf->window),
+                                MAP_SIZE + MINI_MAP_SIZE + 10,
+                                MAP_SIZE + 20);
+    gtk_signal_connect(GTK_OBJECT(conf->window), "destroy",
+                       GTK_SIGNAL_FUNC(byebye), conf);
+    gtk_window_set_title(GTK_WINDOW(conf->window), "Finale Prologin 2001");
+    gtk_window_set_policy(GTK_WINDOW(conf->window), FALSE, FALSE, TRUE);
+    gtk_widget_show(conf->window);
 
-  table = gtk_table_new(3, 4, FALSE);
-  gtk_container_add(GTK_CONTAINER(conf->window), table);
+    table = gtk_table_new(3, 4, FALSE);
+    gtk_container_add(GTK_CONTAINER(conf->window), table);
 
-  conf->tooltips = gtk_tooltips_new();
-  conf->status = create_statusbar(conf);
-  gtk_table_attach_defaults(GTK_TABLE(table), conf->status, 0, 3, 3, 4);
-  widget = create_menubar(conf);
-  gtk_table_attach_defaults(GTK_TABLE(table), widget, 0, 3, 0, 1);
-  widget = create_toolbar(conf);
-  gtk_table_attach_defaults(GTK_TABLE(table), widget, 2, 3, 1, 3);
-  widget = create_game_area(conf);
-  gtk_table_attach_defaults(GTK_TABLE(table), widget, 0, 2, 1, 3);
+    conf->tooltips = gtk_tooltips_new();
+    conf->status = create_statusbar(conf);
+    gtk_table_attach_defaults(GTK_TABLE(table), conf->status, 0, 3, 3, 4);
+    widget = create_menubar(conf);
+    gtk_table_attach_defaults(GTK_TABLE(table), widget, 0, 3, 0, 1);
+    widget = create_toolbar(conf);
+    gtk_table_attach_defaults(GTK_TABLE(table), widget, 2, 3, 1, 3);
+    widget = create_game_area(conf);
+    gtk_table_attach_defaults(GTK_TABLE(table), widget, 0, 2, 1, 3);
 
-  gtk_widget_show(table);
+    gtk_widget_show(table);
 }
 
 static void create_connect(conf_t *conf)
 {
-  GtkWidget *wid, *table;
+    GtkWidget *wid, *table;
 
-  table = gtk_table_new(2, 3, FALSE);
-  gtk_widget_show(table);  
+    table = gtk_table_new(2, 3, FALSE);
+    gtk_widget_show(table);
 
-  gtk_table_attach_defaults(GTK_TABLE(table), create_label("Machine: "),
-			    0, 1, 0, 1);
-  wid = create_entry(conf->host, 80);
-  gtk_signal_connect(GTK_OBJECT(wid), "changed", set_data_from_entry,
-		     &(conf->host));
-  gtk_signal_connect(GTK_OBJECT(wid), "activate",
-		     GTK_SIGNAL_FUNC(callback_connect), conf);
-  gtk_tooltips_set_tip(conf->tooltips, wid, "Machine où se trouve le seveur",
-		       "");
-  gtk_signal_connect(GTK_OBJECT(wid), "activate",
-		     GTK_SIGNAL_FUNC(callback_connect), conf);
-  gtk_signal_connect_after(GTK_OBJECT(wid), "activate", hide_widget, 
-			   conf->conf);
-  gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 0, 1);
+    gtk_table_attach_defaults(GTK_TABLE(table), create_label("Machine: "),
+                              0, 1, 0, 1);
+    wid = create_entry(conf->host, 80);
+    gtk_signal_connect(GTK_OBJECT(wid), "changed", set_data_from_entry,
+                       &( conf->host ));
+    gtk_signal_connect(GTK_OBJECT(wid), "activate",
+                       GTK_SIGNAL_FUNC(callback_connect), conf);
+    gtk_tooltips_set_tip(conf->tooltips, wid, "Machine o� se trouve le seveur",
+                         "");
+    gtk_signal_connect(GTK_OBJECT(wid), "activate",
+                       GTK_SIGNAL_FUNC(callback_connect), conf);
+    gtk_signal_connect_after(GTK_OBJECT(wid), "activate", hide_widget,
+                             conf->conf);
+    gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 0, 1);
 
-  gtk_table_attach_defaults(GTK_TABLE(table), create_label("Port: "),
-			    0, 1, 1, 2);
-  wid = create_spin(1024, 65535, conf->port);
-  gtk_tooltips_set_tip(conf->tooltips, wid, "Port sur lequel le seveur écoute",
-		       "");
-  gtk_signal_connect(GTK_OBJECT(wid), "changed", set_data_from_spin,
-		     &(conf->port));
-  gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 1, 2);
-  conf->conf = create_dialog("Connexion à un serveur", table,
-			     " Se connecter ", " Annuler ", 
-			     GTK_SIGNAL_FUNC(callback_connect), conf,
-			     hide_widget);
+    gtk_table_attach_defaults(GTK_TABLE(table), create_label("Port: "),
+                              0, 1, 1, 2);
+    wid = create_spin(1024, 65535, conf->port);
+    gtk_tooltips_set_tip(conf->tooltips, wid, "Port sur lequel le seveur �coute",
+                         "");
+    gtk_signal_connect(GTK_OBJECT(wid), "changed", set_data_from_spin,
+                       &( conf->port ));
+    gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 1, 2);
+    conf->conf = create_dialog("Connexion � un serveur", table,
+                               " Se connecter ", " Annuler ",
+                               GTK_SIGNAL_FUNC(callback_connect), conf,
+                               hide_widget);
 }
 
 void create_gtk_stuff(conf_t *conf)
 {
-  create_mainbox(conf);
-  create_connect(conf);
-  create_stats(conf);
-  gtk_widget_show(conf->window);
+    create_mainbox(conf);
+    create_connect(conf);
+    create_stats(conf);
+    gtk_widget_show(conf->window);
 }

+ 90 - 72
gclient/map.c

@@ -1,114 +1,132 @@
-/* $Id: map.c,v 1.19 2001/04/29 22:24:37 kilobug Exp $ */
-
 #include "client.h"
 
 static void destroy_player(player_t *player)
 {
-  if (player == NULL)
-    return;
-  destroy_picture(player->akx);
-  destroy_picture(player->r4d2);
-  g_free(player->gdkcol);
-  g_free(player);
+    if ( player == NULL )
+    {
+        return;
+    }
+    destroy_picture(player->akx);
+    destroy_picture(player->r4d2);
+    g_free(player->gdkcol);
+    g_free(player);
 }
 
 void destroy_map(conf_t *conf)
 {
-  int i;
+    int i;
 
-  conf->ready = FALSE;
-  if (conf->map == NULL)
-    return;
-  if (conf->map->players != NULL)
+    conf->ready = FALSE;
+    if ( conf->map == NULL )
     {
-      for (i = 0; i <= conf->map->nb_players; i++)
-	destroy_player(conf->map->players[i]);
-      g_free(conf->map->players);
+        return;
     }
-  if (conf->map->objects != NULL)
+    if ( conf->map->players != NULL )
     {
-      for (i = 0; i < conf->map->nb_objects; i++)
-	if (conf->map->objects[i] != NULL)
-	  g_free(conf->map->objects[i]);
-      g_free(conf->map->objects);
+        for ( i = 0 ; i <= conf->map->nb_players ; i++ )
+        {
+            destroy_player(conf->map->players[i]);
+        }
+        g_free(conf->map->players);
     }
-  g_free(conf->map->sand_file);
-  destroy_picture(conf->map->background);
-  g_free(conf->map);
-  conf->map = NULL;
+    if ( conf->map->objects != NULL )
+    {
+        for ( i = 0 ; i < conf->map->nb_objects ; i++ )
+        {
+            if ( conf->map->objects[i] != NULL )
+            {
+                g_free(conf->map->objects[i]);
+            }
+        }
+        g_free(conf->map->objects);
+    }
+    g_free(conf->map->sand_file);
+    destroy_picture(conf->map->background);
+    g_free(conf->map);
+    conf->map = NULL;
 }
 
 static void update_players(conf_t *conf)
 {
-  int id, i;
+    int id, i;
 
-  while ((i = net_chk_str_list(conf->socket, "UPL", "END", NULL)) == 0)
+    while (( i = net_chk_str_list(conf->socket, "UPL", "END", NULL)) == 0 )
+    {
+        id = net_get_int(conf->socket);
+        conf->map->players[id]->score = net_get_float(conf->socket);
+    }
+    if ( i < 0 )
     {
-      id = net_get_int(conf->socket);
-      conf->map->players[id]->score = net_get_float(conf->socket);
+        protocol_error(conf, "UPL or END expected");
     }
-  if (i < 0)
-    protocol_error(conf, "UPL or END expected");
-  net_send_ack(conf->file);
-  player_list_refresh(conf);
-  stats_refresh(conf);
+    net_send_ack(conf->file);
+    player_list_refresh(conf);
+    stats_refresh(conf);
 }
 
 static void update_objects(conf_t *conf)
 {
-  int id, i;
+    int id, i;
 
-  while ((i = net_chk_str_list(conf->socket, "UOB", "END", NULL)) == 0)
+    while (( i = net_chk_str_list(conf->socket, "UOB", "END", NULL)) == 0 )
     {
-      id = net_get_int(conf->socket);
-      get_object_param(conf->socket, conf->map->objects[id], conf);
-      conf->map->objects[id]->changed = TRUE;
-    }  
-  if (i < 0)
-    protocol_error(conf, "UOB or END expected");
-  net_send_ack(conf->file);    
+        id = net_get_int(conf->socket);
+        get_object_param(conf->socket, conf->map->objects[id], conf);
+        conf->map->objects[id]->changed = TRUE;
+    }
+    if ( i < 0 )
+    {
+        protocol_error(conf, "UOB or END expected");
+    }
+    net_send_ack(conf->file);
 }
 
 static void update_map(conf_t *conf)
 {
-  int i = 0;
+    int i = 0;
 
-  conf->ready = FALSE;
-  i = net_chk_str_list(conf->socket, "TRN", "BYE", NULL);
-  if (i == -1)
+    conf->ready = FALSE;
+    i = net_chk_str_list(conf->socket, "TRN", "BYE", NULL);
+    if ( i == -1 )
+    {
+        protocol_error(conf, "TRN expected");
+        return;
+    }
+    if ( i == 1 )
+    {
+        net_send_ack(conf->file);
+        close_socket(conf);
+        set_status(conf, "Match termin�.");
+        return;
+    }
+    i = net_get_int(conf->socket);
+    conf->map->turn_num = CLAMP(i, 0, conf->map->nb_turns);
+    net_send_ack(conf->file);
+    update_players(conf);
+    for ( i = 0 ; i < conf->map->nb_objects ; i++ )
     {
-      protocol_error(conf, "TRN expected");
-      return;
+        conf->map->objects[i]->changed = FALSE;
     }
-  if (i == 1)
+    update_objects(conf);
+    conf->ready = TRUE;
+    gamearea_refresh(conf->main, conf);
+    minimap_refresh(conf->mini, conf);
+    if (( conf->debug ) && ( conf->turn.mode == tt_skip ))
     {
-      net_send_ack(conf->file);
-      close_socket(conf);
-      set_status(conf, "Match terminé.");
-      return;
+        conf->turn.st_turns--;
+        if ( !conf->turn.st_turns )
+        {
+            conf->turn.mode = tt_pause;
+        }
+        allow_new_turn(conf);
     }
-  i = net_get_int(conf->socket);
-  conf->map->turn_num = CLAMP(i, 0, conf->map->nb_turns);
-  net_send_ack(conf->file);
-  update_players(conf);
-  for (i = 0; i < conf->map->nb_objects; i++)
-    conf->map->objects[i]->changed = FALSE;
-  update_objects(conf);
-  conf->ready = TRUE;
-  gamearea_refresh(conf->main, conf);
-  minimap_refresh(conf->mini, conf);
-  if ((conf->debug) && (conf->turn.mode == tt_skip))
+    if (( conf->debug ) && ( conf->turn.mode == tt_fwd ))
     {
-      conf->turn.st_turns--;
-      if (!conf->turn.st_turns)
-	conf->turn.mode = tt_pause;
-      allow_new_turn(conf);
+        conf->turn.gtkto = gtk_timeout_add(conf->turn.spd, tb_new_turn, conf);
     }
-  if ((conf->debug) && (conf->turn.mode == tt_fwd))
-    conf->turn.gtkto = gtk_timeout_add(conf->turn.spd, tb_new_turn, conf);  
 }
 
 void update_map_callback(void *conf, gint src, GdkInputCondition cond)
 {
-  update_map(conf);
+    update_map(conf);
 }

+ 94 - 87
gclient/menubar.c

@@ -1,123 +1,130 @@
-/* $Id: menubar.c,v 1.11 2001/04/20 10:25:10 kilobug Exp $ */
-
 #include "client.h"
 
 static void menu_disp_about(GtkWidget *wi, conf_t *conf)
 {
-  GtkWidget *dialog;
-  GtkWidget *widget;
-  GtkAccelGroup *accel_group;
+    GtkWidget *dialog;
+    GtkWidget *widget;
+    GtkAccelGroup *accel_group;
 
-  dialog = gtk_dialog_new();
-  accel_group = gtk_accel_group_new();
-  gtk_window_add_accel_group(GTK_WINDOW(&(GTK_DIALOG(dialog)->window)), 
-			     accel_group);
-  gtk_container_set_border_width(GTK_CONTAINER(&(GTK_DIALOG(dialog)->window)),
-				 7);
-  gtk_window_set_title(GTK_WINDOW(&(GTK_DIALOG(dialog)->window)), 
-				  "Finale Prologin 2001");
-  widget = gtk_label_new("Client GTK+ version "VERSION
-			 "\n\nContact: info@prologin.org");
-  gtk_widget_show(widget);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 9);
-  widget = gtk_button_new_with_label(" OK ");
-  gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
-                              GTK_ACCEL_VISIBLE);
-  gtk_widget_show(widget);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), widget, TRUE, 
-		     TRUE, 0);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(destroy_widget), dialog); 
-  gtk_widget_show(dialog);
+    dialog = gtk_dialog_new();
+    accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(&( GTK_DIALOG(dialog)->window )),
+                               accel_group);
+    gtk_container_set_border_width(GTK_CONTAINER(&( GTK_DIALOG(dialog)->window )),
+                                   7);
+    gtk_window_set_title(GTK_WINDOW(&( GTK_DIALOG(dialog)->window )),
+                         "Finale Prologin 2001");
+    widget = gtk_label_new("Client GTK+ version "
+    VERSION
+    "\n\nContact: info@prologin.org");
+    gtk_widget_show(widget);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 9);
+    widget = gtk_button_new_with_label(" OK ");
+    gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
+                               GTK_ACCEL_VISIBLE);
+    gtk_widget_show(widget);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), widget, TRUE,
+                       TRUE, 0);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(destroy_widget), dialog);
+    gtk_widget_show(dialog);
 }
 
 static void menu_disp_connect(GtkWidget *wi, conf_t *conf)
 {
-  gtk_widget_show(conf->conf);
+    gtk_widget_show(conf->conf);
 }
 
 static void menu_stat(GtkWidget *wi, conf_t *conf)
 {
-  conf->stat.on = !conf->stat.on;
-  if (conf->stat.on)
-    gtk_widget_show(conf->stat.stat);
-  else
-    gtk_widget_hide(conf->stat.stat);
+    conf->stat.on = !conf->stat.on;
+    if ( conf->stat.on )
+    {
+        gtk_widget_show(conf->stat.stat);
+    }
+    else
+    {
+        gtk_widget_hide(conf->stat.stat);
+    }
 }
 
 static void menu_ttip(GtkCheckMenuItem *wi, conf_t *conf)
 {
-  if (wi->active)
-    gtk_tooltips_enable(conf->tooltips);
-  else
-    gtk_tooltips_disable(conf->tooltips);
+    if ( wi->active )
+    {
+        gtk_tooltips_enable(conf->tooltips);
+    }
+    else
+    {
+        gtk_tooltips_disable(conf->tooltips);
+    }
 }
 
 static void menu_stop(GtkWidget *wi, conf_t *conf)
 {
-  conf->terminated = TRUE;
-  allow_new_turn(conf);
+    conf->terminated = TRUE;
+    allow_new_turn(conf);
 }
 
 static GtkItemFactoryEntry gtk_menu_items[] = {
-      { "/_Système",            NULL,         NULL, 0, "<Branch>" },
-      { "/Système/C_onnecter",  "<control>O", menu_disp_connect, 0, NULL },
-      { "/Système/sep1",        NULL,         NULL, 0, "<Separator>" },
-      { "/Système/_Quitter",    "<control>Q", byebye, 0, NULL },
-      { "/_Simulation",         NULL,         NULL, 0, "<Branch>" },
-      { "/Simulation/_Stats",    "<control>S", menu_stat, 5, "<ToggleItem>" },
-      { "/_Aide",               NULL,         NULL, 0, "<LastBranch>" },
-      { "/_Aide/_Bulles d'aide", "<control>B", menu_ttip, 4, "<ToggleItem>" },
-      { "/_Aide/_A propos",     NULL,         menu_disp_about, 0, NULL },
-    };
+        { "/_Syst�me",             NULL,         NULL,              0, "<Branch>" },
+        { "/Syst�me/C_onnecter",   "<control>O", menu_disp_connect, 0, NULL },
+        { "/Syst�me/sep1",         NULL,         NULL,              0, "<Separator>" },
+        { "/Syst�me/_Quitter",     "<control>Q", byebye,            0, NULL },
+        { "/_Simulation",          NULL,         NULL,              0, "<Branch>" },
+        { "/Simulation/_Stats",    "<control>S", menu_stat,         5, "<ToggleItem>" },
+        { "/_Aide",                NULL,         NULL,              0, "<LastBranch>" },
+        { "/_Aide/_Bulles d'aide", "<control>B", menu_ttip,         4, "<ToggleItem>" },
+        { "/_Aide/_A propos",      NULL,         menu_disp_about,   0, NULL },
+};
 
 static GtkItemFactoryEntry gtk_menu_items_debug[] = {
-      { "/_Système",            NULL,         NULL, 0, "<Branch>" },
-      { "/Système/C_onnecter",  "<control>O", menu_disp_connect, 0, NULL },
-      { "/Système/sep1",        NULL,         NULL, 0, "<Separator>" },
-      { "/Système/_Quitter",    "<control>Q", byebye, 0, NULL },
-      { "/_Simulation",         NULL,         NULL, 0, "<Branch>" },
-      { "/Simulation/_Pause",   "<control>P", tb_pause, 0, NULL },
-      { "/Simulation/_Tour suivant",  "<control>T", tb_play, 0, NULL },
-      { "/Simulation/_N tours",  "<control>N", tb_step, 0, NULL },
-      { "/Simulation/_Continuer",  "<control>C", tb_ffwd, 0, NULL },
-      { "/Simulation/Arreter",  "<control>A", menu_stop, 0, NULL },
-      { "/Simulation/sep1",     NULL,         NULL, 0, "<Separator>" },
-      { "/Simulation/_Stats",    "<control>S", menu_stat, 5, "<ToggleItem>" },
-      { "/_Aide",               NULL,         NULL, 0, "<LastBranch>" },
-      { "/_Aide/_Bulles d'aide", "<control>B", menu_ttip, 4, "<ToggleItem>" },
-      { "/_Aide/_A propos",     NULL,         menu_disp_about, 0, NULL },
-    };
+        { "/_Syst�me",                 NULL,         NULL,              0, "<Branch>" },
+        { "/Syst�me/C_onnecter",       "<control>O", menu_disp_connect, 0, NULL },
+        { "/Syst�me/sep1",             NULL,         NULL,              0, "<Separator>" },
+        { "/Syst�me/_Quitter",         "<control>Q", byebye,            0, NULL },
+        { "/_Simulation",              NULL,         NULL,              0, "<Branch>" },
+        { "/Simulation/_Pause",        "<control>P", tb_pause,          0, NULL },
+        { "/Simulation/_Tour suivant", "<control>T", tb_play,           0, NULL },
+        { "/Simulation/_N tours",      "<control>N", tb_step,           0, NULL },
+        { "/Simulation/_Continuer",    "<control>C", tb_ffwd,           0, NULL },
+        { "/Simulation/Arreter",       "<control>A", menu_stop,         0, NULL },
+        { "/Simulation/sep1",          NULL,         NULL,              0, "<Separator>" },
+        { "/Simulation/_Stats",        "<control>S", menu_stat,         5, "<ToggleItem>" },
+        { "/_Aide",                    NULL,         NULL,              0, "<LastBranch>" },
+        { "/_Aide/_Bulles d'aide",     "<control>B", menu_ttip,         4, "<ToggleItem>" },
+        { "/_Aide/_A propos",          NULL,         menu_disp_about,   0, NULL },
+};
 
 GtkWidget *create_menubar(conf_t *conf)
 {
-  GtkItemFactory *item_factory = NULL;
-  GtkAccelGroup	*accel_group  = NULL;
-  GtkWidget *widget = NULL, *ttip = NULL;
-  GtkItemFactoryEntry *menu_items;
-  int nmenu_items;
+    GtkItemFactory *item_factory = NULL;
+    GtkAccelGroup *accel_group = NULL;
+    GtkWidget *widget = NULL, *ttip = NULL;
+    GtkItemFactoryEntry *menu_items;
+    int nmenu_items;
 
-  if (conf->debug)
+    if ( conf->debug )
     {
-      menu_items = gtk_menu_items_debug;
-      nmenu_items = sizeof (gtk_menu_items_debug) / sizeof (menu_items[0]);
+        menu_items = gtk_menu_items_debug;
+        nmenu_items = sizeof(gtk_menu_items_debug) / sizeof(menu_items[0]);
     }
-  else
+    else
     {
-      menu_items = gtk_menu_items;
-      nmenu_items = sizeof (gtk_menu_items) / sizeof (menu_items[0]);
+        menu_items = gtk_menu_items;
+        nmenu_items = sizeof(gtk_menu_items) / sizeof(menu_items[0]);
     }
 
-  accel_group = gtk_accel_group_new();
-  item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", 
-				      accel_group);
-  gtk_item_factory_create_items_ac(item_factory, nmenu_items, menu_items, 
-				   conf, 2);
-  gtk_window_add_accel_group(GTK_WINDOW(conf->window), accel_group);
-  widget = gtk_item_factory_get_widget(item_factory, "<main>");
-  conf->stat.menu = gtk_item_factory_get_widget_by_action(item_factory, 5);
-  ttip = gtk_item_factory_get_widget_by_action(item_factory, 4);
-  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ttip), TRUE);
-  gtk_widget_show(widget);
-  return widget;
+    accel_group = gtk_accel_group_new();
+    item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>",
+                                        accel_group);
+    gtk_item_factory_create_items_ac(item_factory, nmenu_items, menu_items,
+                                     conf, 2);
+    gtk_window_add_accel_group(GTK_WINDOW(conf->window), accel_group);
+    widget = gtk_item_factory_get_widget(item_factory, "<main>");
+    conf->stat.menu = gtk_item_factory_get_widget_by_action(item_factory, 5);
+    ttip = gtk_item_factory_get_widget_by_action(item_factory, 4);
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ttip), TRUE);
+    gtk_widget_show(widget);
+    return widget;
 }

+ 62 - 56
gclient/minimap.c

@@ -1,82 +1,88 @@
-/* $Id: minimap.c,v 1.10 2001/04/14 23:40:39 kilobug Exp $ */
-
 #include "client.h"
 
 void minimap_refresh(GtkWidget *w, const conf_t *conf)
 {
-  gdk_draw_rgb_32_image(w->window, 
-			w->style->fg_gc[GTK_STATE_NORMAL],
-			0, 0, MINI_MAP_SIZE, MINI_MAP_SIZE, 
-			GDK_RGB_DITHER_NORMAL,
-			gen_minimap(conf, TRUE),
-			MINI_MAP_SIZE * 4);
+    gdk_draw_rgb_32_image(w->window,
+                          w->style->fg_gc[GTK_STATE_NORMAL],
+                          0, 0, MINI_MAP_SIZE, MINI_MAP_SIZE,
+                          GDK_RGB_DITHER_NORMAL,
+                          gen_minimap(conf, TRUE),
+                          MINI_MAP_SIZE * 4);
 }
 
-static gint mini_expose_event(GtkWidget *w, GdkEventExpose *e, 
-			      const conf_t *conf)
+static gint mini_expose_event(GtkWidget *w, GdkEventExpose *e,
+                              const conf_t *conf)
 {
-  guint offs;
+    guint offs;
 
-  offs = (e->area.x + e->area.y * MINI_MAP_SIZE) * 4;
-  gdk_draw_rgb_32_image(w->window, 
-			w->style->fg_gc[GTK_WIDGET_STATE(w)],
-			e->area.x, e->area.y, 
-			e->area.width, e->area.height,
-			GDK_RGB_DITHER_NORMAL,
-			gen_minimap(conf, FALSE) + offs,
-			MINI_MAP_SIZE * 4);
-  return FALSE;
+    offs = ( e->area.x + e->area.y * MINI_MAP_SIZE ) * 4;
+    gdk_draw_rgb_32_image(w->window,
+                          w->style->fg_gc[GTK_WIDGET_STATE(w)],
+                          e->area.x, e->area.y,
+                          e->area.width, e->area.height,
+                          GDK_RGB_DITHER_NORMAL,
+                          gen_minimap(conf, FALSE) + offs,
+                          MINI_MAP_SIZE * 4);
+    return FALSE;
 }
 
 static void mini_press_event(GtkWidget *w, GdkEventButton *e, conf_t *conf)
 {
-  if ((e->button != 1) || (conf == NULL))
-    return;
-  scroll_bigmap(conf, e->x, e->y);
+    if (( e->button != 1 ) || ( conf == NULL ))
+    {
+        return;
+    }
+    scroll_bigmap(conf, e->x, e->y);
 }
 
 static void mini_motion_event(GtkWidget *w, GdkEventMotion *e, conf_t *conf)
 {
-  int x, y;
-  GdkModifierType state;
+    int x, y;
+    GdkModifierType state;
 
-  if (conf == NULL)
-    return;
-  if (e->is_hint)
-    gdk_window_get_pointer(e->window, &x, &y, &state);
-  else
+    if ( conf == NULL )
+    {
+        return;
+    }
+    if ( e->is_hint )
+    {
+        gdk_window_get_pointer(e->window, &x, &y, &state);
+    }
+    else
+    {
+        x = e->x;
+        y = e->y;
+        state = e->state;
+    }
+    if ( !( state & GDK_BUTTON1_MASK ))
     {
-      x = e->x;
-      y = e->y;
-      state = e->state;
+        return;
     }
-  if (!(state & GDK_BUTTON1_MASK))
-    return;
-  scroll_bigmap(conf, x, y);
+    scroll_bigmap(conf, x, y);
 }
 
 GtkWidget *create_mini_map(conf_t *conf)
 {
-  GtkWidget *frame;
+    GtkWidget *frame;
 
-  frame = create_frame("Minimap");
+    frame = create_frame("Minimap");
 
-  conf->mini = gtk_drawing_area_new();
-  gtk_drawing_area_size(GTK_DRAWING_AREA(conf->mini),
-			MINI_MAP_SIZE, MINI_MAP_SIZE);
-  gtk_signal_connect(GTK_OBJECT(conf->mini), "expose_event",
-		     (GtkSignalFunc) mini_expose_event, conf);
-  gtk_signal_connect(GTK_OBJECT(conf->mini), "button_press_event",
-		     (GtkSignalFunc) mini_press_event, conf);
-  gtk_signal_connect(GTK_OBJECT(conf->mini), "motion_notify_event",
-		     (GtkSignalFunc) mini_motion_event, conf);
-  gtk_widget_set_events(conf->mini, 
-			GDK_EXPOSURE_MASK
-			| GDK_LEAVE_NOTIFY_MASK
-			| GDK_BUTTON_PRESS_MASK
-			| GDK_POINTER_MOTION_MASK
-			| GDK_POINTER_MOTION_HINT_MASK);
-  gtk_widget_show(conf->mini);
-  gtk_container_add(GTK_CONTAINER(frame), conf->mini);  
-  return frame;
+    conf->mini = gtk_drawing_area_new();
+    gtk_drawing_area_size(GTK_DRAWING_AREA(conf->mini),
+                          MINI_MAP_SIZE, MINI_MAP_SIZE);
+    gtk_signal_connect(GTK_OBJECT(conf->mini), "expose_event",
+                       (GtkSignalFunc) mini_expose_event, conf);
+    gtk_signal_connect(GTK_OBJECT(conf->mini), "button_press_event",
+                       (GtkSignalFunc) mini_press_event, conf);
+    gtk_signal_connect(GTK_OBJECT(conf->mini), "motion_notify_event",
+                       (GtkSignalFunc) mini_motion_event, conf);
+    gtk_widget_set_events(conf->mini,
+                          GDK_EXPOSURE_MASK
+                          | GDK_LEAVE_NOTIFY_MASK
+                          | GDK_BUTTON_PRESS_MASK
+                          | GDK_POINTER_MOTION_MASK
+                          | GDK_POINTER_MOTION_HINT_MASK);
+    gtk_widget_show(conf->mini);
+    gtk_container_add(GTK_CONTAINER(frame), conf->mini);
+    return frame;
 }

+ 123 - 107
gclient/network.c

@@ -1,149 +1,165 @@
-/* $Id: network.c,v 1.14 2001/04/29 22:24:37 kilobug Exp $ */
-
 #include "client.h"
 
 void send_goodbye(conf_t *conf)
 {
-  if ((conf->connected) && (conf->debug))
+    if (( conf->connected ) && ( conf->debug ))
     {
-      net_wr_string(conf->file, "END");
-      fflush(conf->file);
-      net_wait_ack(conf->socket);
-      net_chk_string(conf->socket, "BYE");
-      net_send_ack(conf->file);      
+        net_wr_string(conf->file, "END");
+        fflush(conf->file);
+        net_wait_ack(conf->socket);
+        net_chk_string(conf->socket, "BYE");
+        net_send_ack(conf->file);
+    }
+    if ( conf->connected )
+    {
+        close_socket(conf);
     }
-  if (conf->connected)
-    close_socket(conf);
 }
 
 void network_error(net_type_t get, net_type_t wanted, void *data)
-{  
-  char buf[100];
-  conf_t *conf;
+{
+    char buf[100];
+    conf_t *conf;
 
-  conf = data;
-  if ((conf == NULL) || (!conf->connected))
-    return;
-  conf->connected = FALSE;
-  g_snprintf(buf, 100, 
-	     "Erreur réseau: `wanted (%s), get (%s)'. Connexion perdue.\n", 
-	     net_type_name(wanted), net_type_name(get));
-  set_status(conf, buf);
+    conf = data;
+    if (( conf == NULL ) || ( !conf->connected ))
+    {
+        return;
+    }
+    conf->connected = FALSE;
+    g_snprintf(buf, 100,
+               "Erreur r�seau: `wanted (%s), get (%s)'. Connexion perdue.\n",
+               net_type_name(wanted), net_type_name(get));
+    set_status(conf, buf);
 }
 
 void do_connect(conf_t *conf)
 {
-  char buf[420];
-  
-  send_goodbye(conf);
-  conf->terminated = FALSE;
-  snprintf(buf, 420, "Connexion en cours sur %s:%d...", conf->host, 
-	   conf->port);
-  set_status(conf, buf);
+    char buf[420];
+
+    send_goodbye(conf);
+    conf->terminated = FALSE;
+    snprintf(buf, 420, "Connexion en cours sur %s:%d...", conf->host,
+             conf->port);
+    set_status(conf, buf);
 
-  conf->socket = net_connect_to(conf->host, conf->port, buf, 420, NULL);
-  if (conf->socket == -1)
+    conf->socket = net_connect_to(conf->host, conf->port, buf, 420, NULL);
+    if ( conf->socket == -1 )
     {
-      set_status(conf, buf);
-      return;
+        set_status(conf, buf);
+        return;
     }
-  snprintf(buf, 420, 
-	   "Connexion établie avec %s:%d... authentification en cours.", 
-	   conf->host, conf->port);
-  set_status(conf, buf);
-  conf->connected = TRUE;
-  conf->file = fdopen(conf->socket, "w");
+    snprintf(buf, 420,
+             "Connexion �tablie avec %s:%d... authentification en cours.",
+             conf->host, conf->port);
+    set_status(conf, buf);
+    conf->connected = TRUE;
+    conf->file = fdopen(conf->socket, "w");
 
-  net_wr_string(conf->file, "HELLO 42");
-  fflush(conf->file);
-  if (!net_chk_string(conf->socket, "HELLO 42"))
+    net_wr_string(conf->file, "HELLO 42");
+    fflush(conf->file);
+    if ( !net_chk_string(conf->socket, "HELLO 42"))
     {
-      snprintf(buf, 420, "%s:%d n'est pas un serveur Prologin.", 
-	       conf->host, conf->port);
-      set_status(conf, buf);
-      conf->socket = -1;
-      return;
+        snprintf(buf, 420, "%s:%d n'est pas un serveur Prologin.",
+                 conf->host, conf->port);
+        set_status(conf, buf);
+        conf->socket = -1;
+        return;
     }
-  net_wr_int(conf->file, PROTOCOL_VERSION);
-  fflush(conf->file);
-  if (!net_wait_ack(conf->socket))
+    net_wr_int(conf->file, PROTOCOL_VERSION);
+    fflush(conf->file);
+    if ( !net_wait_ack(conf->socket))
     {
-      snprintf(buf, 420, "%s:%d connexion refusée (mauvaise version).", 
-	       conf->host, conf->port);
-      set_status(conf, buf);
-      conf->socket = -1;
-      return;
+        snprintf(buf, 420, "%s:%d connexion refus�e (mauvaise version).",
+                 conf->host, conf->port);
+        set_status(conf, buf);
+        conf->socket = -1;
+        return;
     }
-  net_wr_flag(conf->file, conf->debug);
-  fflush(conf->file);
-  if (!net_wait_ack(conf->socket))
+    net_wr_flag(conf->file, conf->debug);
+    fflush(conf->file);
+    if ( !net_wait_ack(conf->socket))
     {
-      snprintf(buf, 420, "%s:%d connexion refusée (mauvais type de client).", 
-	       conf->host, conf->port);
-      set_status(conf, buf);
-      conf->socket = -1;
-      return;
+        snprintf(buf, 420, "%s:%d connexion refus�e (mauvais type de client).",
+                 conf->host, conf->port);
+        set_status(conf, buf);
+        conf->socket = -1;
+        return;
     }
-  net_send_ack(conf->file);
-  load_map(conf);
-  conf->gdk_io_id = gdk_input_add(conf->socket, GDK_INPUT_READ, 
-				  update_map_callback, conf);
-  snprintf(buf, 420, 
-	   "Connexion établie avec %s:%d.", 
-	   conf->host, conf->port);
-  set_status(conf, buf);
+    net_send_ack(conf->file);
+    load_map(conf);
+    conf->gdk_io_id = gdk_input_add(conf->socket, GDK_INPUT_READ,
+                                    update_map_callback, conf);
+    snprintf(buf, 420,
+             "Connexion �tablie avec %s:%d.",
+             conf->host, conf->port);
+    set_status(conf, buf);
 
-  if (conf->conf != NULL)
-    gtk_widget_hide(conf->conf);
+    if ( conf->conf != NULL )
+    {
+        gtk_widget_hide(conf->conf);
+    }
 }
-  
+
 void protocol_error(conf_t *conf, const char *msg)
 {
-  char buf[420];
+    char buf[420];
 
-  net_send_abort(conf->file);
-  close_socket(conf);
-  fprintf(stderr, "Erreur fatale de protocole avec %s:%d: %s.\n", 
-	  conf->host, conf->port, msg);
-  snprintf(buf, 420, "Erreur fatale de protocole avec %s:%d: %s.", 
-	   conf->host, conf->port, msg);
-  set_status(conf, buf);
-  conf->ready = FALSE;
+    net_send_abort(conf->file);
+    close_socket(conf);
+    fprintf(stderr, "Erreur fatale de protocole avec %s:%d: %s.\n",
+            conf->host, conf->port, msg);
+    snprintf(buf, 420, "Erreur fatale de protocole avec %s:%d: %s.",
+             conf->host, conf->port, msg);
+    set_status(conf, buf);
+    conf->ready = FALSE;
 }
 
 void close_socket(conf_t *conf)
 {
-  if (conf->socket > 0)
+    if ( conf->socket > 0 )
     {
-      if (conf->gdk_io_id >= 0)
-	gdk_input_remove(conf->gdk_io_id);
-      conf->connected = FALSE;
-      fclose(conf->file);
-      conf->socket = -1;
-      conf->file = NULL;
+        if ( conf->gdk_io_id >= 0 )
+        {
+            gdk_input_remove(conf->gdk_io_id);
+        }
+        conf->connected = FALSE;
+        fclose(conf->file);
+        conf->socket = -1;
+        conf->file = NULL;
     }
 }
 
 void allow_new_turn(conf_t *conf)
-{  
-  if (!conf->connected)
-    return;
-  if (!conf->ready)
-    return;
-  conf->ready = FALSE;
-  if (conf->gdk_io_id >= 0)
-    gdk_input_remove(conf->gdk_io_id);
-  if (conf->terminated)
+{
+    if ( !conf->connected )
+    {
+        return;
+    }
+    if ( !conf->ready )
+    {
+        return;
+    }
+    conf->ready = FALSE;
+    if ( conf->gdk_io_id >= 0 )
+    {
+        gdk_input_remove(conf->gdk_io_id);
+    }
+    if ( conf->terminated )
+    {
+        send_goodbye(conf);
+        return;
+    }
+    else
+    {
+        net_wr_string(conf->file, "GO");
+    }
+    fflush(conf->file);
+    if ( !net_wait_ack(conf->socket))
     {
-      send_goodbye(conf);
-      return;
+        protocol_error(conf, "expected ACK.");
     }
-  else
-    net_wr_string(conf->file, "GO");
-  fflush(conf->file);
-  if (!net_wait_ack(conf->socket))
-    protocol_error(conf, "expected ACK.");
-  conf->gdk_io_id = gdk_input_add(conf->socket, GDK_INPUT_READ, 
-				  update_map_callback, conf);
+    conf->gdk_io_id = gdk_input_add(conf->socket, GDK_INPUT_READ,
+                                    update_map_callback, conf);
 }
 

+ 118 - 96
gclient/pixbuf.c

@@ -1,125 +1,147 @@
-/* $Id: pixbuf.c,v 1.6 2001/04/29 22:07:44 kilobug Exp $ */
-
 #include "client.h"
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 image_t *load_picture(const char *filename, const char *mask)
 {
-  image_t *res;
-  guchar *data = NULL, *mdata = NULL;
-  GdkPixbuf *pixbuf, *pbmask = NULL;
-  int x, y, sx2, bpp;
-  char *s;
+    image_t *res;
+    guchar *data = NULL, *mdata = NULL;
+    GdkPixbuf *pixbuf, *pbmask = NULL;
+    int x, y, sx2, bpp;
+    char *s;
 
-  if (getenv("PROLO_DATA_DIR") == NULL)
+    if ( getenv("PROLO_DATA_DIR") == NULL )
+    {
+        fprintf(stderr, "Variable PROLO_DATA_DIR invalide.\n");
+        exit(1);
+    }
+    res = g_malloc(sizeof(*res));
+    res->sx = res->sy = 0;
+    res->data = NULL;
+    if ( !g_path_is_absolute(filename))
+    {
+        res->name = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S,
+                                filename, NULL);
+    }
+    else
+    {
+        res->name = g_strdup(filename);
+    }
+    pixbuf = gdk_pixbuf_new_from_file(res->name);
+    if ( pixbuf == NULL )
     {
-      fprintf(stderr, "Variable PROLO_DATA_DIR invalide.\n");
-      exit(1);
+        fprintf(stderr, "Erreur lors du chargement de l'image: %s\n", res->name);
+        g_free(res->name);
+        g_free(res);
+        return NULL;
     }
-  res = g_malloc(sizeof(*res));
-  res->sx = res->sy = 0;
-  res->data = NULL;
-  if (!g_path_is_absolute(filename))
-    res->name = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S, 
-			    filename, NULL);
-  else
-    res->name = g_strdup(filename);
-  pixbuf = gdk_pixbuf_new_from_file(res->name);
-  if (pixbuf == NULL)
+    if ( mask != NULL )
     {
-      fprintf(stderr, "Erreur lors du chargement de l'image: %s\n", res->name);
-      g_free(res->name);
-      g_free(res);
-      return NULL;
+        if ( !g_path_is_absolute(mask))
+        {
+            s = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S, mask,
+                            NULL);
+        }
+        else
+        {
+            s = g_strdup(mask);
+        }
+        pbmask = gdk_pixbuf_new_from_file(s);
+        mdata = gdk_pixbuf_get_pixels(pbmask);
+        g_free(s);
     }
-  if (mask != NULL)
+    res->sx = gdk_pixbuf_get_width(pixbuf);
+    res->sy = gdk_pixbuf_get_height(pixbuf);
+    res->data = g_malloc(res->sx * res->sy * 4);
+    data = gdk_pixbuf_get_pixels(pixbuf);
+    sx2 = gdk_pixbuf_get_rowstride(pixbuf);
+    bpp = gdk_pixbuf_get_has_alpha(pixbuf) ? 4 : 3;
+    for ( x = 0 ; x < res->sx ; x++ )
     {
-      if (!g_path_is_absolute(mask))
-	s = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S, mask, 
-			NULL);
-      else
-	s = g_strdup(mask);
-      pbmask = gdk_pixbuf_new_from_file(s);
-      mdata = gdk_pixbuf_get_pixels(pbmask);
-      g_free(s);
+        for ( y = 0 ; y < res->sy ; y++ )
+        {
+            memcpy(res->data + ( x + y * res->sx ) * 4, data + x * bpp + y * sx2, 3);
+            if ( mdata != NULL )
+            {
+                res->data[( x + y * res->sx ) * 4 + 3] = mdata[x * bpp + y * sx2];
+            }
+            else
+            {
+                res->data[( x + y * res->sx ) * 4 + 3] = 0;
+            }
+        }
     }
-  res->sx = gdk_pixbuf_get_width(pixbuf);
-  res->sy = gdk_pixbuf_get_height(pixbuf);
-  res->data = g_malloc(res->sx * res->sy * 4);
-  data = gdk_pixbuf_get_pixels(pixbuf);
-  sx2 = gdk_pixbuf_get_rowstride(pixbuf);
-  bpp = gdk_pixbuf_get_has_alpha(pixbuf) ? 4 : 3;
-  for (x = 0; x < res->sx; x++)
-    for (y = 0; y < res->sy; y++)
-      {
-	memcpy(res->data + (x + y * res->sx) * 4, data + x * bpp + y * sx2, 3);
-	if (mdata != NULL)
-	  res->data[(x + y * res->sx) * 4 + 3] = mdata[x * bpp + y * sx2];
-	else
-	  res->data[(x + y * res->sx) * 4 + 3] = 0;
-      }
-  gdk_pixbuf_unref(pixbuf);
-  if (pbmask != NULL)
-    gdk_pixbuf_unref(pbmask);
-  return res;
+    gdk_pixbuf_unref(pixbuf);
+    if ( pbmask != NULL )
+    {
+        gdk_pixbuf_unref(pbmask);
+    }
+    return res;
 }
 
 void destroy_picture(image_t *pic)
 {
-  if (pic == NULL)
-    return;
-  g_free(pic->data);
-  g_free(pic->name);
-  g_free(pic);
+    if ( pic == NULL )
+    {
+        return;
+    }
+    g_free(pic->data);
+    g_free(pic->name);
+    g_free(pic);
 }
 
 image_t *dup_picture(const image_t *src)
 {
-  image_t *res;
-  int size;
+    image_t *res;
+    int size;
 
-  res = g_malloc(sizeof(*res));
-  res->sx = src->sx;
-  res->sy = src->sy;
-  res->name = g_strdup(src->name);
-  size = src->sx * src->sy * 4;
-  res->data = g_malloc(size);
-  memcpy(res->data, src->data, size);
-  return res;
+    res = g_malloc(sizeof(*res));
+    res->sx = src->sx;
+    res->sy = src->sy;
+    res->name = g_strdup(src->name);
+    size = src->sx * src->sy * 4;
+    res->data = g_malloc(size);
+    memcpy(res->data, src->data, size);
+    return res;
 }
 
 image_t *tint_picture(const image_t *src, guchar *col)
 {
-  image_t *res;
-  int temp;
-  int ofs, size;
+    image_t *res;
+    int temp;
+    int ofs, size;
 
-  res = g_malloc(sizeof(*res));
-  res->sx = src->sx;
-  res->sy = src->sy;
-  res->name = g_strdup(src->name);
-  size = src->sx * src->sy * 4;
-  res->data = g_malloc(size);
-  for (ofs = 0; ofs < size; ofs += 4)
+    res = g_malloc(sizeof(*res));
+    res->sx = src->sx;
+    res->sy = src->sy;
+    res->name = g_strdup(src->name);
+    size = src->sx * src->sy * 4;
+    res->data = g_malloc(size);
+    for ( ofs = 0 ; ofs < size ; ofs += 4 )
     {
-      if (src->data[ofs + 3] == 0)
-	{
-	  temp = col[2] / SPRITE_COLOR_DIV + (int)src->data[ofs];
-	  if (temp > 0xFF)
-	    temp = 0xFF;
-	  res->data[ofs] = (guchar) temp;
-	  
-	  temp = col[1] / SPRITE_COLOR_DIV + (int)src->data[ofs + 1];
-	  if (temp > 0xFF)
-	    temp = 0xFF;
-	  res->data[ofs + 1] = (guchar) temp;
-	  
-	  temp = col[0] / SPRITE_COLOR_DIV + (int)src->data[ofs + 2];
-	  if (temp > 0xFF)
-	    temp = 0xFF;
-	  res->data[ofs + 2] = (guchar) temp;
-	}
-      res->data[ofs + 3] = src->data[ofs + 3];
+        if ( src->data[ofs + 3] == 0 )
+        {
+            temp = col[2] / SPRITE_COLOR_DIV + (int) src->data[ofs];
+            if ( temp > 0xFF )
+            {
+                temp = 0xFF;
+            }
+            res->data[ofs] = (guchar) temp;
+
+            temp = col[1] / SPRITE_COLOR_DIV + (int) src->data[ofs + 1];
+            if ( temp > 0xFF )
+            {
+                temp = 0xFF;
+            }
+            res->data[ofs + 1] = (guchar) temp;
+
+            temp = col[0] / SPRITE_COLOR_DIV + (int) src->data[ofs + 2];
+            if ( temp > 0xFF )
+            {
+                temp = 0xFF;
+            }
+            res->data[ofs + 2] = (guchar) temp;
+        }
+        res->data[ofs + 3] = src->data[ofs + 3];
     }
-  return res;
+    return res;
 }

+ 77 - 74
gclient/players.c

@@ -1,106 +1,109 @@
-/* $Id: players.c,v 1.10 2001/04/25 14:31:33 kilobug Exp $ */
-
 #include "client.h"
 
 static int pl_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
-  switch (clist->sort_column)
+    switch ( clist->sort_column )
     {
     case 1:
-      return clist_compare_str(clist, ptr1, ptr2);
-    case 0: case 2:
-      return clist_compare_float(clist, ptr1, ptr2);
+        return clist_compare_str(clist, ptr1, ptr2);
+    case 0:
+    case 2:
+        return clist_compare_float(clist, ptr1, ptr2);
     }
-  return 0;
+    return 0;
 }
 
 void player_list_refresh(const conf_t *conf)
 {
-  char score[10];
-  player_t *pl;
-  int i;
+    char score[10];
+    player_t *pl;
+    int i;
 
-  if (conf->map->players == NULL)
-    return;
-  gtk_clist_freeze(GTK_CLIST(conf->pl));
-  for (i = 0; i < conf->map->nb_players; i++)
+    if ( conf->map->players == NULL )
+    {
+        return;
+    }
+    gtk_clist_freeze(GTK_CLIST(conf->pl));
+    for ( i = 0 ; i < conf->map->nb_players ; i++ )
     {
-      pl = gtk_clist_get_row_data(GTK_CLIST(conf->pl), i); 
-      g_snprintf(score, 10, "%.2f", pl->score);
-      gtk_clist_set_text(GTK_CLIST(conf->pl), i, 2, score);
+        pl = gtk_clist_get_row_data(GTK_CLIST(conf->pl), i);
+        g_snprintf(score, 10, "%.2f", pl->score);
+        gtk_clist_set_text(GTK_CLIST(conf->pl), i, 2, score);
     }
-  gtk_clist_sort(GTK_CLIST(conf->pl));
-  gtk_clist_thaw(GTK_CLIST(conf->pl));
-  gtk_progress_configure(GTK_PROGRESS(conf->turn_bar), conf->map->turn_num,
-			 0, conf->map->nb_turns);
+    gtk_clist_sort(GTK_CLIST(conf->pl));
+    gtk_clist_thaw(GTK_CLIST(conf->pl));
+    gtk_progress_configure(GTK_PROGRESS(conf->turn_bar), conf->map->turn_num,
+                           0, conf->map->nb_turns);
 }
 
 void pl_make_color(GdkColor *col, int r, int g, int b)
 {
-  col->pixel = 0;
-  col->red = r * 257;
-  col->green = g * 257;
-  col->blue = b * 257;
-  gdk_colormap_alloc_color(gdk_colormap_get_system(), col, FALSE, TRUE);
+    col->pixel = 0;
+    col->red = r * 257;
+    col->green = g * 257;
+    col->blue = b * 257;
+    gdk_colormap_alloc_color(gdk_colormap_get_system(), col, FALSE, TRUE);
 }
 
 void player_list_make(conf_t *conf)
 {
-  char **tb;
-  char id[4], score[10];
-  player_t *pl;
-  int i, j;
-  
-  if (conf->map->players == NULL)
-    return;
-  gtk_clist_freeze(GTK_CLIST(conf->pl));
-  gtk_clist_clear(GTK_CLIST(conf->pl));
-  tb = g_malloc(sizeof(*tb) * 4);
-  tb[0] = id;
-  tb[2] = score;
-  tb[3] = NULL;
-  for (i = 1; i <= conf->map->nb_players; i++)
+    char **tb;
+    char id[4], score[10];
+    player_t *pl;
+    int i, j;
+
+    if ( conf->map->players == NULL )
+    {
+        return;
+    }
+    gtk_clist_freeze(GTK_CLIST(conf->pl));
+    gtk_clist_clear(GTK_CLIST(conf->pl));
+    tb = g_malloc(sizeof(*tb) * 4);
+    tb[0] = id;
+    tb[2] = score;
+    tb[3] = NULL;
+    for ( i = 1 ; i <= conf->map->nb_players ; i++ )
     {
-      pl = conf->map->players[i];
-      tb[1] = pl->name;
-      g_snprintf(id, 4, "%d", pl->id);
-      g_snprintf(score, 10, "%.2f", pl->score);
-      j = gtk_clist_append(GTK_CLIST(conf->pl), tb);
-      gtk_clist_set_row_data(GTK_CLIST(conf->pl), j, pl);
-      gtk_clist_set_foreground(GTK_CLIST(conf->pl), j, pl->gdkcol);
-      gtk_clist_set_compare_func(GTK_CLIST(conf->pl), pl_sort);
+        pl = conf->map->players[i];
+        tb[1] = pl->name;
+        g_snprintf(id, 4, "%d", pl->id);
+        g_snprintf(score, 10, "%.2f", pl->score);
+        j = gtk_clist_append(GTK_CLIST(conf->pl), tb);
+        gtk_clist_set_row_data(GTK_CLIST(conf->pl), j, pl);
+        gtk_clist_set_foreground(GTK_CLIST(conf->pl), j, pl->gdkcol);
+        gtk_clist_set_compare_func(GTK_CLIST(conf->pl), pl_sort);
     }
-  g_free(tb);
-  gtk_clist_thaw(GTK_CLIST(conf->pl));  
-  gtk_progress_configure(GTK_PROGRESS(conf->turn_bar), conf->map->turn_num,
-			 0, conf->map->nb_turns);
+    g_free(tb);
+    gtk_clist_thaw(GTK_CLIST(conf->pl));
+    gtk_progress_configure(GTK_PROGRESS(conf->turn_bar), conf->map->turn_num,
+                           0, conf->map->nb_turns);
 }
 
 GtkWidget *create_players_list(conf_t *conf)
 {
-  GtkWidget *frame, *vbox;
+    GtkWidget *frame, *vbox;
 
-  frame = create_frame("Général");
-  conf->pl = create_clist(3, 2,
-			  "Equipe", "Nom", "Score", 
-			  40, 100, 60,
-			  GTK_SORT_ASCENDING, 
-			  GTK_SORT_ASCENDING,
-			  GTK_SORT_DESCENDING);
-  clist_set_tooltips(GTK_CLIST(conf->pl), conf->tooltips, "Trier par équipe",
-		     "Trier par nom", "Trier par score", NULL);
+    frame = create_frame("G�n�ral");
+    conf->pl = create_clist(3, 2,
+                            "Equipe", "Nom", "Score",
+                            40, 100, 60,
+                            GTK_SORT_ASCENDING,
+                            GTK_SORT_ASCENDING,
+                            GTK_SORT_DESCENDING);
+    clist_set_tooltips(GTK_CLIST(conf->pl), conf->tooltips, "Trier par �quipe",
+                       "Trier par nom", "Trier par score", NULL);
 
-  conf->turn_bar = gtk_progress_bar_new();
-  gtk_progress_set_format_string(GTK_PROGRESS(conf->turn_bar), 
- 				 "%v/%u (%p %%)");
-  gtk_progress_set_show_text(GTK_PROGRESS(conf->turn_bar), TRUE);
-  gtk_progress_configure(GTK_PROGRESS(conf->turn_bar), 0, 0, 1);
-  gtk_widget_show(conf->turn_bar);
+    conf->turn_bar = gtk_progress_bar_new();
+    gtk_progress_set_format_string(GTK_PROGRESS(conf->turn_bar),
+                                   "%v/%u (%p %%)");
+    gtk_progress_set_show_text(GTK_PROGRESS(conf->turn_bar), TRUE);
+    gtk_progress_configure(GTK_PROGRESS(conf->turn_bar), 0, 0, 1);
+    gtk_widget_show(conf->turn_bar);
 
-  vbox = gtk_vbox_new(FALSE, 5);
-  gtk_box_pack_start(GTK_BOX(vbox), conf->pl, TRUE, TRUE, 5);  
-  gtk_box_pack_start(GTK_BOX(vbox), conf->turn_bar, TRUE, TRUE, 5);
-  gtk_widget_show(vbox);
-  gtk_container_add(GTK_CONTAINER(frame), vbox);  
-  return frame; 
+    vbox = gtk_vbox_new(FALSE, 5);
+    gtk_box_pack_start(GTK_BOX(vbox), conf->pl, TRUE, TRUE, 5);
+    gtk_box_pack_start(GTK_BOX(vbox), conf->turn_bar, TRUE, TRUE, 5);
+    gtk_widget_show(vbox);
+    gtk_container_add(GTK_CONTAINER(frame), vbox);
+    return frame;
 }

+ 327 - 278
gclient/stats.c

@@ -1,5 +1,3 @@
-/* $Id: stats.c,v 1.11 2001/05/06 01:23:05 kilobug Exp $ */
-
 #include "client.h"
 
 #define STAT_BUF_SIZE 42
@@ -7,360 +5,411 @@
 /* Calcul des infos */
 static int stat_count_objects(conf_t *conf, int id, obj_type_t type)
 {
-  int i, r;
+    int i, r;
 
-  if ((type == obj_r4d2) && (id == 0))
-    return 0;
-  r = 0;
-  for (i = 0; i < conf->map->nb_objects; i++)
-    if ((conf->map->objects[i]->type == type) &&
-	(conf->map->objects[i]->team_id == id))
-      r++;
-  return r;
+    if (( type == obj_r4d2 ) && ( id == 0 ))
+    {
+        return 0;
+    }
+    r = 0;
+    for ( i = 0 ; i < conf->map->nb_objects ; i++ )
+    {
+        if (( conf->map->objects[i]->type == type ) &&
+            ( conf->map->objects[i]->team_id == id ))
+        {
+            r++;
+        }
+    }
+    return r;
 }
 
 static void stat_make_buf_r4d2(obj_t *obj, char **tb)
 {
-  g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->team_id);
-  g_snprintf(tb[1], STAT_BUF_SIZE, "%.2f", obj->posx);
-  g_snprintf(tb[2], STAT_BUF_SIZE, "%.2f", obj->posy);
+    g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->team_id);
+    g_snprintf(tb[1], STAT_BUF_SIZE, "%.2f", obj->posx);
+    g_snprintf(tb[2], STAT_BUF_SIZE, "%.2f", obj->posy);
 }
 
 static void stat_make_buf_akx(obj_t *obj, char **tb)
 {
-  g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->team_id);
-  g_snprintf(tb[1], STAT_BUF_SIZE, "%.2f", obj->posx);
-  g_snprintf(tb[2], STAT_BUF_SIZE, "%.2f", obj->posy);
-  switch (obj->action)
+    g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->team_id);
+    g_snprintf(tb[1], STAT_BUF_SIZE, "%.2f", obj->posx);
+    g_snprintf(tb[2], STAT_BUF_SIZE, "%.2f", obj->posy);
+    switch ( obj->action )
     {
     case act_akx_move:
-      g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "Déplacement");
-      g_snprintf(tb[4], STAT_BUF_SIZE, "(%.2f ; %.2f)", obj->tx, obj->ty);
-      break;
+        g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "D�placement");
+        g_snprintf(tb[4], STAT_BUF_SIZE, "(%.2f ; %.2f)", obj->tx, obj->ty);
+        break;
     case act_akx_pulse:
-      g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "Pulse");
-      g_snprintf(tb[4], STAT_BUF_SIZE, "(%.2f ; %.2f)", obj->tx, obj->ty);
-      break;
+        g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "Pulse");
+        g_snprintf(tb[4], STAT_BUF_SIZE, "(%.2f ; %.2f)", obj->tx, obj->ty);
+        break;
     case act_akx_link:
-      g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "Lien");
-      g_snprintf(tb[4], STAT_BUF_SIZE, "%d", obj->target);
-      break;
+        g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "Lien");
+        g_snprintf(tb[4], STAT_BUF_SIZE, "%d", obj->target);
+        break;
     default:
-      g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "Erreur");
-      g_snprintf(tb[4], STAT_BUF_SIZE, "Aucune");
-      break;
+        g_snprintf(tb[3], STAT_BUF_SIZE, "%s", "Erreur");
+        g_snprintf(tb[4], STAT_BUF_SIZE, "Aucune");
+        break;
     }
 }
 
 static void stat_obj_color(GtkCList *clist, conf_t *conf, obj_t *obj, int j)
 {
-  int i;
+    int i;
 
-  i = obj->team_id;
-  if (i > conf->map->nb_players)
-    i = 0;
-  gtk_clist_set_foreground(clist, j, conf->map->players[i]->gdkcol);
+    i = obj->team_id;
+    if ( i > conf->map->nb_players )
+    {
+        i = 0;
+    }
+    gtk_clist_set_foreground(clist, j, conf->map->players[i]->gdkcol);
 }
 
 /* Remplissage des listes */
 static void stat_append_player(conf_t *conf, player_t *pl, char **tb)
 {
-  char *s;
-  int j;
-
-  s = tb[1];
-  g_snprintf(tb[0], STAT_BUF_SIZE, "%d", pl->id);
-  tb[1] = pl->name;      
-  g_snprintf(tb[2], STAT_BUF_SIZE, "%d", 
-	     stat_count_objects(conf, pl->id, obj_akx));
-  g_snprintf(tb[3], STAT_BUF_SIZE, "%d", 
-	     stat_count_objects(conf, pl->id, obj_r4d2));
-  g_snprintf(tb[4], STAT_BUF_SIZE, "%.2f", pl->score);
-  j = gtk_clist_append(GTK_CLIST(conf->stat.pl), tb);
-  gtk_clist_set_row_data(GTK_CLIST(conf->stat.pl), j, pl);
-  gtk_clist_set_foreground(GTK_CLIST(conf->stat.pl), j, pl->gdkcol);
-  tb[1] = s;
+    char *s;
+    int j;
+
+    s = tb[1];
+    g_snprintf(tb[0], STAT_BUF_SIZE, "%d", pl->id);
+    tb[1] = pl->name;
+    g_snprintf(tb[2], STAT_BUF_SIZE, "%d",
+               stat_count_objects(conf, pl->id, obj_akx));
+    g_snprintf(tb[3], STAT_BUF_SIZE, "%d",
+               stat_count_objects(conf, pl->id, obj_r4d2));
+    g_snprintf(tb[4], STAT_BUF_SIZE, "%.2f", pl->score);
+    j = gtk_clist_append(GTK_CLIST(conf->stat.pl), tb);
+    gtk_clist_set_row_data(GTK_CLIST(conf->stat.pl), j, pl);
+    gtk_clist_set_foreground(GTK_CLIST(conf->stat.pl), j, pl->gdkcol);
+    tb[1] = s;
 }
 
 static void stat_append_r4d2(conf_t *conf, obj_t *obj, char **tb)
 {
-  int j;
+    int j;
 
-  g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->id);
-  stat_make_buf_r4d2(obj, tb + 1);
-  j = gtk_clist_append(GTK_CLIST(conf->stat.r4d2), tb);
-  gtk_clist_set_row_data(GTK_CLIST(conf->stat.r4d2), j, obj);
-  stat_obj_color(GTK_CLIST(conf->stat.r4d2), conf, obj, j);
+    g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->id);
+    stat_make_buf_r4d2(obj, tb + 1);
+    j = gtk_clist_append(GTK_CLIST(conf->stat.r4d2), tb);
+    gtk_clist_set_row_data(GTK_CLIST(conf->stat.r4d2), j, obj);
+    stat_obj_color(GTK_CLIST(conf->stat.r4d2), conf, obj, j);
 }
 
 static void stat_append_akx(conf_t *conf, obj_t *obj, char **tb)
 {
-  int j;
+    int j;
 
-  g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->id);
-  stat_make_buf_akx(obj, tb + 1);
-  j = gtk_clist_append(GTK_CLIST(conf->stat.akx), tb);
-  gtk_clist_set_row_data(GTK_CLIST(conf->stat.akx), j, obj);
-  stat_obj_color(GTK_CLIST(conf->stat.akx), conf, obj, j);
+    g_snprintf(tb[0], STAT_BUF_SIZE, "%d", obj->id);
+    stat_make_buf_akx(obj, tb + 1);
+    j = gtk_clist_append(GTK_CLIST(conf->stat.akx), tb);
+    gtk_clist_set_row_data(GTK_CLIST(conf->stat.akx), j, obj);
+    stat_obj_color(GTK_CLIST(conf->stat.akx), conf, obj, j);
 }
 
 void stats_make(conf_t *conf)
 {
-  char **tb;
-  player_t *pl;
-  int i;
-  obj_t *obj;
-  
-  if (conf->map->players == NULL)
-    return;
-  if (conf->map->objects == NULL)
-    return;
-  tb = g_malloc(sizeof(*tb) * 6);
-  for (i = 0; i < 6; i++)
-    tb[i] = g_malloc(STAT_BUF_SIZE);
-
-  gtk_clist_freeze(GTK_CLIST(conf->stat.pl));
-  gtk_clist_clear(GTK_CLIST(conf->stat.pl));
-  for (i = 0; i <= conf->map->nb_players; i++)
+    char **tb;
+    player_t *pl;
+    int i;
+    obj_t *obj;
+
+    if ( conf->map->players == NULL )
+    {
+        return;
+    }
+    if ( conf->map->objects == NULL )
+    {
+        return;
+    }
+    tb = g_malloc(sizeof(*tb) * 6);
+    for ( i = 0 ; i < 6 ; i++ )
     {
-      pl = conf->map->players[i];
-      stat_append_player(conf, pl, tb);
+        tb[i] = g_malloc(STAT_BUF_SIZE);
     }
-  gtk_clist_sort(GTK_CLIST(conf->stat.pl));
-  gtk_clist_thaw(GTK_CLIST(conf->stat.pl));
-  
-  gtk_clist_freeze(GTK_CLIST(conf->stat.r4d2));
-  gtk_clist_freeze(GTK_CLIST(conf->stat.akx));
-  gtk_clist_clear(GTK_CLIST(conf->stat.r4d2));
-  gtk_clist_clear(GTK_CLIST(conf->stat.akx));
-  for (i = 0; i < conf->map->nb_objects; i++)
+
+    gtk_clist_freeze(GTK_CLIST(conf->stat.pl));
+    gtk_clist_clear(GTK_CLIST(conf->stat.pl));
+    for ( i = 0 ; i <= conf->map->nb_players ; i++ )
+    {
+        pl = conf->map->players[i];
+        stat_append_player(conf, pl, tb);
+    }
+    gtk_clist_sort(GTK_CLIST(conf->stat.pl));
+    gtk_clist_thaw(GTK_CLIST(conf->stat.pl));
+
+    gtk_clist_freeze(GTK_CLIST(conf->stat.r4d2));
+    gtk_clist_freeze(GTK_CLIST(conf->stat.akx));
+    gtk_clist_clear(GTK_CLIST(conf->stat.r4d2));
+    gtk_clist_clear(GTK_CLIST(conf->stat.akx));
+    for ( i = 0 ; i < conf->map->nb_objects ; i++ )
     {
-      obj = conf->map->objects[i];
-      if (obj == NULL)
-	continue;
-      if (obj->type == obj_akx)
-	stat_append_akx(conf, obj, tb);
-      else
-	stat_append_r4d2(conf, obj, tb);
+        obj = conf->map->objects[i];
+        if ( obj == NULL )
+        {
+            continue;
+        }
+        if ( obj->type == obj_akx )
+        {
+            stat_append_akx(conf, obj, tb);
+        }
+        else
+        {
+            stat_append_r4d2(conf, obj, tb);
+        }
     }
-  gtk_clist_sort(GTK_CLIST(conf->stat.r4d2));
-  gtk_clist_sort(GTK_CLIST(conf->stat.akx));
-  gtk_clist_thaw(GTK_CLIST(conf->stat.r4d2));
-  gtk_clist_thaw(GTK_CLIST(conf->stat.akx));
-
-  for (i = 0; i < 6; i++)
-    g_free(tb[i]);
-  g_free(tb);
+    gtk_clist_sort(GTK_CLIST(conf->stat.r4d2));
+    gtk_clist_sort(GTK_CLIST(conf->stat.akx));
+    gtk_clist_thaw(GTK_CLIST(conf->stat.r4d2));
+    gtk_clist_thaw(GTK_CLIST(conf->stat.akx));
+
+    for ( i = 0 ; i < 6 ; i++ )
+    {
+        g_free(tb[i]);
+    }
+    g_free(tb);
 }
 
-/* Mise à jour des infos */
+/* Mise � jour des infos */
 static void stat_update_player(conf_t *conf, int i, char *tb)
 {
-  player_t *pl;
-
-  pl =  gtk_clist_get_row_data(GTK_CLIST(conf->stat.pl), i);
-  g_snprintf(tb, STAT_BUF_SIZE, "%d", 
-	     stat_count_objects(conf, pl->id, obj_akx));
-  gtk_clist_set_text(GTK_CLIST(conf->stat.pl), i, 2, tb);
-  g_snprintf(tb, STAT_BUF_SIZE, "%d", 
-	     stat_count_objects(conf, pl->id, obj_r4d2));
-  gtk_clist_set_text(GTK_CLIST(conf->stat.pl), i, 3, tb);
-  g_snprintf(tb, STAT_BUF_SIZE, "%.2f", pl->score);
-  gtk_clist_set_text(GTK_CLIST(conf->stat.pl), i, 4, tb);
+    player_t *pl;
+
+    pl = gtk_clist_get_row_data(GTK_CLIST(conf->stat.pl), i);
+    g_snprintf(tb, STAT_BUF_SIZE, "%d",
+               stat_count_objects(conf, pl->id, obj_akx));
+    gtk_clist_set_text(GTK_CLIST(conf->stat.pl), i, 2, tb);
+    g_snprintf(tb, STAT_BUF_SIZE, "%d",
+               stat_count_objects(conf, pl->id, obj_r4d2));
+    gtk_clist_set_text(GTK_CLIST(conf->stat.pl), i, 3, tb);
+    g_snprintf(tb, STAT_BUF_SIZE, "%.2f", pl->score);
+    gtk_clist_set_text(GTK_CLIST(conf->stat.pl), i, 4, tb);
 }
 
 static void stat_update_akx(conf_t *conf, int i, char **tb)
 {
-  obj_t *obj;
-  int j;
-
-  obj = gtk_clist_get_row_data(GTK_CLIST(conf->stat.akx), i);
-  if (!obj->changed)
-    return;
-  stat_make_buf_akx(obj, tb);
-  for (j = 0; j < 5; j++)
-    gtk_clist_set_text(GTK_CLIST(conf->stat.akx), i, j + 1, tb[j]);
-  stat_obj_color(GTK_CLIST(conf->stat.akx), conf, obj, i);
+    obj_t *obj;
+    int j;
+
+    obj = gtk_clist_get_row_data(GTK_CLIST(conf->stat.akx), i);
+    if ( !obj->changed )
+    {
+        return;
+    }
+    stat_make_buf_akx(obj, tb);
+    for ( j = 0 ; j < 5 ; j++ )
+    {
+        gtk_clist_set_text(GTK_CLIST(conf->stat.akx), i, j + 1, tb[j]);
+    }
+    stat_obj_color(GTK_CLIST(conf->stat.akx), conf, obj, i);
 }
 
 static void stat_update_r4d2(conf_t *conf, int i, char **tb)
 {
-  obj_t *obj;
-  int j;
-
-  obj = gtk_clist_get_row_data(GTK_CLIST(conf->stat.r4d2), i);
-  if (!obj->changed)
-    return;
-  stat_make_buf_r4d2(obj, tb);
-  for (j = 0; j < 3; j++)
-    gtk_clist_set_text(GTK_CLIST(conf->stat.r4d2), i, j + 1, tb[j]);
-  stat_obj_color(GTK_CLIST(conf->stat.r4d2), conf, obj, i);
+    obj_t *obj;
+    int j;
+
+    obj = gtk_clist_get_row_data(GTK_CLIST(conf->stat.r4d2), i);
+    if ( !obj->changed )
+    {
+        return;
+    }
+    stat_make_buf_r4d2(obj, tb);
+    for ( j = 0 ; j < 3 ; j++ )
+    {
+        gtk_clist_set_text(GTK_CLIST(conf->stat.r4d2), i, j + 1, tb[j]);
+    }
+    stat_obj_color(GTK_CLIST(conf->stat.r4d2), conf, obj, i);
 }
 
 void stats_refresh(conf_t *conf)
 {
-  int i;
-  char **tb;
-  
-  if (conf->map->players == NULL)
-    return;
-  if (conf->map->objects == NULL)
-    return;
-  tb = g_malloc(sizeof(*tb) * 5);
-  for (i = 0; i < 5; i++)
-    tb[i] = g_malloc(STAT_BUF_SIZE);
-
-  gtk_clist_freeze(GTK_CLIST(conf->stat.pl));
-  for (i = 0; i <= conf->map->nb_players; i++)
-    stat_update_player(conf, i, tb[0]);
-  gtk_clist_sort(GTK_CLIST(conf->stat.pl));  
-  gtk_clist_thaw(GTK_CLIST(conf->stat.pl));  
-
-  gtk_clist_freeze(GTK_CLIST(conf->stat.akx));
-  for (i = 0; i < conf->map->nb_akx; i++)
-    stat_update_akx(conf, i, tb);
-  gtk_clist_sort(GTK_CLIST(conf->stat.akx));  
-  gtk_clist_thaw(GTK_CLIST(conf->stat.akx));  
-
-  gtk_clist_freeze(GTK_CLIST(conf->stat.r4d2));
-  for (i = 0; i < conf->map->nb_r4d2; i++)
-    stat_update_r4d2(conf, i, tb);
-  gtk_clist_sort(GTK_CLIST(conf->stat.r4d2));  
-  gtk_clist_thaw(GTK_CLIST(conf->stat.r4d2));  
-
-  for (i = 0; i < 5; i++)
-    g_free(tb[i]);
-  g_free(tb);
+    int i;
+    char **tb;
+
+    if ( conf->map->players == NULL )
+    {
+        return;
+    }
+    if ( conf->map->objects == NULL )
+    {
+        return;
+    }
+    tb = g_malloc(sizeof(*tb) * 5);
+    for ( i = 0 ; i < 5 ; i++ )
+    {
+        tb[i] = g_malloc(STAT_BUF_SIZE);
+    }
+
+    gtk_clist_freeze(GTK_CLIST(conf->stat.pl));
+    for ( i = 0 ; i <= conf->map->nb_players ; i++ )
+    {
+        stat_update_player(conf, i, tb[0]);
+    }
+    gtk_clist_sort(GTK_CLIST(conf->stat.pl));
+    gtk_clist_thaw(GTK_CLIST(conf->stat.pl));
+
+    gtk_clist_freeze(GTK_CLIST(conf->stat.akx));
+    for ( i = 0 ; i < conf->map->nb_akx ; i++ )
+    {
+        stat_update_akx(conf, i, tb);
+    }
+    gtk_clist_sort(GTK_CLIST(conf->stat.akx));
+    gtk_clist_thaw(GTK_CLIST(conf->stat.akx));
+
+    gtk_clist_freeze(GTK_CLIST(conf->stat.r4d2));
+    for ( i = 0 ; i < conf->map->nb_r4d2 ; i++ )
+    {
+        stat_update_r4d2(conf, i, tb);
+    }
+    gtk_clist_sort(GTK_CLIST(conf->stat.r4d2));
+    gtk_clist_thaw(GTK_CLIST(conf->stat.r4d2));
+
+    for ( i = 0 ; i < 5 ; i++ )
+    {
+        g_free(tb[i]);
+    }
+    g_free(tb);
 }
 
-/* Création des widgets */
+/* Cr�ation des widgets */
 static int players_sort(GtkCList *clist, gconstpointer p1, gconstpointer p2)
 {
-  switch (clist->sort_column)
+    switch ( clist->sort_column )
     {
-    case 1: 
-      return clist_compare_str(clist, p1, p2);
-    case 0: case 2: case 3: case 4:
-      return clist_compare_float(clist, p1, p2);
+    case 1:
+        return clist_compare_str(clist, p1, p2);
+    case 0:
+    case 2:
+    case 3:
+    case 4:
+        return clist_compare_float(clist, p1, p2);
     }
-  return 0;
+    return 0;
 }
 
 static int objects_sort(GtkCList *clist, gconstpointer p1, gconstpointer p2)
 {
-  switch (clist->sort_column)
+    switch ( clist->sort_column )
     {
-    case 0: case 1: case 2: case 3:
-      return clist_compare_float(clist, p1, p2);
-    case 4: case 5:
-      return clist_compare_str(clist, p1, p2);
+    case 0:
+    case 1:
+    case 2:
+    case 3:
+        return clist_compare_float(clist, p1, p2);
+    case 4:
+    case 5:
+        return clist_compare_str(clist, p1, p2);
     }
-  return 0;
+    return 0;
 }
 
 static void stat_hide(GtkWidget *w, conf_t *data)
 {
-   gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(data->stat.menu), FALSE);
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(data->stat.menu), FALSE);
 }
 
 void create_stats(conf_t *conf)
 {
-  GtkWidget *wind, *wid, *vbox, *frame, *scrolled;
-  GtkAccelGroup *accel_group;
-  
-  wind = gtk_window_new(GTK_WINDOW_DIALOG);
-  gtk_window_set_default_size(GTK_WINDOW(wind), 400, 600);
-  gtk_widget_hide(wind);
-  gtk_container_set_border_width(GTK_CONTAINER(wind), 7);
-  gtk_window_set_title(GTK_WINDOW(wind), "Informations sur le jeu");
-  conf->stat.stat = wind;
-  vbox = gtk_vbox_new(FALSE, 4);
-  gtk_widget_show(vbox);
-  gtk_container_add(GTK_CONTAINER(wind), vbox);
-
-  frame = create_frame("Joueurs");
-  conf->stat.pl = create_clist(5, 4, 
-			       "Equipe", "Nom", "Akx", "R4D2", "Score", 
-			       40, 100, 30, 30, 60,
-			       GTK_SORT_ASCENDING, 
-			       GTK_SORT_ASCENDING,
-			       GTK_SORT_DESCENDING,
-			       GTK_SORT_DESCENDING,
-			       GTK_SORT_DESCENDING);
-  scrolled = gtk_scrolled_window_new(NULL, NULL);
-  gtk_widget_show(scrolled);
-  gtk_container_add(GTK_CONTAINER(scrolled), conf->stat.pl);  
-  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), 
-				 GTK_POLICY_AUTOMATIC,
-				 GTK_POLICY_AUTOMATIC);
-  gtk_container_add(GTK_CONTAINER(frame), scrolled);  
-  gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
-  gtk_clist_set_compare_func(GTK_CLIST(conf->stat.pl), players_sort);
-  gtk_clist_set_auto_sort(GTK_CLIST(conf->stat.pl), FALSE);
-  clist_set_tooltips(GTK_CLIST(conf->stat.pl), conf->tooltips,
-		     "Trier par numéro d'équipe", "Trier par nom", 
-		     "Trier par nombre d'anakronox", 
-		     "Trier par nombre de r4d2", "Trier par score", NULL);
-
-  frame = create_frame("Anakronox");
-  conf->stat.akx = create_clist(6, 0, 
-				"Id", "Equipe", "X", "Y", "Action", "Cible", 
-				20, 40, 40, 40, 50, 60,
-				GTK_SORT_ASCENDING, 
-				GTK_SORT_ASCENDING,
-				GTK_SORT_ASCENDING,
-				GTK_SORT_ASCENDING,
-				GTK_SORT_ASCENDING,
-				GTK_SORT_ASCENDING);
-  scrolled = gtk_scrolled_window_new(NULL, NULL);
-  gtk_widget_show(scrolled);
-  gtk_container_add(GTK_CONTAINER(scrolled), conf->stat.akx);
-  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), 
-				 GTK_POLICY_AUTOMATIC,
-				 GTK_POLICY_AUTOMATIC);
-  gtk_container_add(GTK_CONTAINER(frame), scrolled);  
-  gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
-  gtk_clist_set_compare_func(GTK_CLIST(conf->stat.akx), objects_sort);
-  gtk_clist_set_auto_sort(GTK_CLIST(conf->stat.akx), FALSE);
-  clist_set_tooltips(GTK_CLIST(conf->stat.akx), conf->tooltips,
-		     "Trier par numéro", "Trier par équipe", 
-		     "Trier par position X", "Trier par position Y",
-		     "Trier par action", "Trier par cible", NULL);
-  
-  frame = create_frame("R4D2");
-  conf->stat.r4d2 = create_clist(4, 0,
-				"Id", "Equipe", "X", "Y", 
-				20, 40, 40, 40, 
-				GTK_SORT_ASCENDING, 
-				GTK_SORT_ASCENDING,
-				GTK_SORT_ASCENDING,
-				GTK_SORT_ASCENDING);
-  scrolled = gtk_scrolled_window_new(NULL, NULL);
-  gtk_widget_show(scrolled);
-  gtk_container_add(GTK_CONTAINER(scrolled), conf->stat.r4d2);
-  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), 
-				 GTK_POLICY_AUTOMATIC,
-				 GTK_POLICY_AUTOMATIC);
-  gtk_container_add(GTK_CONTAINER(frame), scrolled);  
-  gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
-  gtk_clist_set_compare_func(GTK_CLIST(conf->stat.r4d2), objects_sort);
-  gtk_clist_set_auto_sort(GTK_CLIST(conf->stat.r4d2), FALSE);
-  clist_set_tooltips(GTK_CLIST(conf->stat.r4d2), conf->tooltips,
-		     "Trier par numéro", "Trier par équipe", 
-		     "Trier par position X", "Trier par position Y", NULL);
-
-  accel_group = gtk_accel_group_new();  
-  gtk_window_add_accel_group(GTK_WINDOW(conf->stat.stat),  accel_group);
-  wid = gtk_button_new_with_label("Fermer");
-  gtk_widget_add_accelerator(wid, "clicked", accel_group, GDK_Return, 0,
-                              GTK_ACCEL_VISIBLE);
-  gtk_signal_connect_object(GTK_OBJECT(wind), "delete_event", 
-			    GTK_SIGNAL_FUNC(gtk_button_clicked), 
-			    GTK_OBJECT(wid));
-  gtk_widget_show(wid);
-  gtk_signal_connect(GTK_OBJECT(wid), "clicked", 
-		     GTK_SIGNAL_FUNC(stat_hide), conf);
-  gtk_box_pack_start(GTK_BOX(vbox), wid, FALSE, FALSE, 5);
-  
+    GtkWidget *wind, *wid, *vbox, *frame, *scrolled;
+    GtkAccelGroup *accel_group;
+
+    wind = gtk_window_new(GTK_WINDOW_DIALOG);
+    gtk_window_set_default_size(GTK_WINDOW(wind), 400, 600);
+    gtk_widget_hide(wind);
+    gtk_container_set_border_width(GTK_CONTAINER(wind), 7);
+    gtk_window_set_title(GTK_WINDOW(wind), "Informations sur le jeu");
+    conf->stat.stat = wind;
+    vbox = gtk_vbox_new(FALSE, 4);
+    gtk_widget_show(vbox);
+    gtk_container_add(GTK_CONTAINER(wind), vbox);
+
+    frame = create_frame("Joueurs");
+    conf->stat.pl = create_clist(5, 4,
+                                 "Equipe", "Nom", "Akx", "R4D2", "Score",
+                                 40, 100, 30, 30, 60,
+                                 GTK_SORT_ASCENDING,
+                                 GTK_SORT_ASCENDING,
+                                 GTK_SORT_DESCENDING,
+                                 GTK_SORT_DESCENDING,
+                                 GTK_SORT_DESCENDING);
+    scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_widget_show(scrolled);
+    gtk_container_add(GTK_CONTAINER(scrolled), conf->stat.pl);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_container_add(GTK_CONTAINER(frame), scrolled);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
+    gtk_clist_set_compare_func(GTK_CLIST(conf->stat.pl), players_sort);
+    gtk_clist_set_auto_sort(GTK_CLIST(conf->stat.pl), FALSE);
+    clist_set_tooltips(GTK_CLIST(conf->stat.pl), conf->tooltips,
+                       "Trier par num�ro d'�quipe", "Trier par nom",
+                       "Trier par nombre d'anakronox",
+                       "Trier par nombre de r4d2", "Trier par score", NULL);
+
+    frame = create_frame("Anakronox");
+    conf->stat.akx = create_clist(6, 0,
+                                  "Id", "Equipe", "X", "Y", "Action", "Cible",
+                                  20, 40, 40, 40, 50, 60,
+                                  GTK_SORT_ASCENDING,
+                                  GTK_SORT_ASCENDING,
+                                  GTK_SORT_ASCENDING,
+                                  GTK_SORT_ASCENDING,
+                                  GTK_SORT_ASCENDING,
+                                  GTK_SORT_ASCENDING);
+    scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_widget_show(scrolled);
+    gtk_container_add(GTK_CONTAINER(scrolled), conf->stat.akx);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_container_add(GTK_CONTAINER(frame), scrolled);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
+    gtk_clist_set_compare_func(GTK_CLIST(conf->stat.akx), objects_sort);
+    gtk_clist_set_auto_sort(GTK_CLIST(conf->stat.akx), FALSE);
+    clist_set_tooltips(GTK_CLIST(conf->stat.akx), conf->tooltips,
+                       "Trier par num�ro", "Trier par �quipe",
+                       "Trier par position X", "Trier par position Y",
+                       "Trier par action", "Trier par cible", NULL);
+
+    frame = create_frame("R4D2");
+    conf->stat.r4d2 = create_clist(4, 0,
+                                   "Id", "Equipe", "X", "Y",
+                                   20, 40, 40, 40,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING);
+    scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_widget_show(scrolled);
+    gtk_container_add(GTK_CONTAINER(scrolled), conf->stat.r4d2);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_container_add(GTK_CONTAINER(frame), scrolled);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
+    gtk_clist_set_compare_func(GTK_CLIST(conf->stat.r4d2), objects_sort);
+    gtk_clist_set_auto_sort(GTK_CLIST(conf->stat.r4d2), FALSE);
+    clist_set_tooltips(GTK_CLIST(conf->stat.r4d2), conf->tooltips,
+                       "Trier par num�ro", "Trier par �quipe",
+                       "Trier par position X", "Trier par position Y", NULL);
+
+    accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(conf->stat.stat), accel_group);
+    wid = gtk_button_new_with_label("Fermer");
+    gtk_widget_add_accelerator(wid, "clicked", accel_group, GDK_Return, 0,
+                               GTK_ACCEL_VISIBLE);
+    gtk_signal_connect_object(GTK_OBJECT(wind), "delete_event",
+                              GTK_SIGNAL_FUNC(gtk_button_clicked),
+                              GTK_OBJECT(wid));
+    gtk_widget_show(wid);
+    gtk_signal_connect(GTK_OBJECT(wid), "clicked",
+                       GTK_SIGNAL_FUNC(stat_hide), conf);
+    gtk_box_pack_start(GTK_BOX(vbox), wid, FALSE, FALSE, 5);
+
 }
 

+ 9 - 11
gclient/statusbar.c

@@ -1,21 +1,19 @@
-/* $Id: statusbar.c,v 1.4 2001/04/08 16:02:28 kilobug Exp $ */
-
 #include "client.h"
 
 void set_status(const conf_t *conf, const char *msg)
 {
-  gtk_statusbar_pop(GTK_STATUSBAR(conf->status), 42);
-  gtk_statusbar_push(GTK_STATUSBAR(conf->status), 42, msg);
-  gtk_main_iteration_do(FALSE);
+    gtk_statusbar_pop(GTK_STATUSBAR(conf->status), 42);
+    gtk_statusbar_push(GTK_STATUSBAR(conf->status), 42, msg);
+    gtk_main_iteration_do(FALSE);
 }
 
 GtkWidget *create_statusbar(conf_t *conf)
 {
-  GtkWidget *widget;
+    GtkWidget *widget;
 
-  widget = gtk_statusbar_new();
-  gtk_statusbar_push(GTK_STATUSBAR(widget), 42, 
-		     "Connexion en cours...");
-  gtk_widget_show(widget);
-  return (widget);
+    widget = gtk_statusbar_new();
+    gtk_statusbar_push(GTK_STATUSBAR(widget), 42,
+                       "Connexion en cours...");
+    gtk_widget_show(widget);
+    return ( widget );
 }

+ 133 - 123
gclient/toolbar.c

@@ -1,170 +1,180 @@
-/* $Id: toolbar.c,v 1.20 2001/04/29 22:07:44 kilobug Exp $ */
-
 #include "client.h"
 
 void tb_pause(GtkWidget *wid, conf_t *conf)
 {
-  if (!conf->connected)
-    return;
-  if (conf->turn.mode == tt_fwd)
-    gtk_timeout_remove(conf->turn.gtkto);
-  conf->turn.gtkto = 0;    
-  conf->turn.mode = tt_pause;
+    if ( !conf->connected )
+    {
+        return;
+    }
+    if ( conf->turn.mode == tt_fwd )
+    {
+        gtk_timeout_remove(conf->turn.gtkto);
+    }
+    conf->turn.gtkto = 0;
+    conf->turn.mode = tt_pause;
 }
 
 void tb_play(GtkWidget *wid, conf_t *conf)
 {
-  if (!conf->connected)
-    return;
-  tb_pause(wid, conf);
-  allow_new_turn(conf);
+    if ( !conf->connected )
+    {
+        return;
+    }
+    tb_pause(wid, conf);
+    allow_new_turn(conf);
 }
 
 void tb_step(GtkWidget *wid, conf_t *conf)
 {
-  if (!conf->connected)
-    return;
-  tb_pause(wid, conf);
-  conf->turn.st_turns = conf->turn.nbt - 1;
-  conf->turn.mode = tt_skip;
-  allow_new_turn(conf);
+    if ( !conf->connected )
+    {
+        return;
+    }
+    tb_pause(wid, conf);
+    conf->turn.st_turns = conf->turn.nbt - 1;
+    conf->turn.mode = tt_skip;
+    allow_new_turn(conf);
 }
 
-gboolean tb_new_turn(void *conf)
+bool tb_new_turn(void *conf)
 {
-  allow_new_turn(conf);
-  return FALSE;
+    allow_new_turn(conf);
+    return FALSE;
 }
 
 void tb_ffwd(GtkWidget *wid, conf_t *conf)
 {
-  if (!conf->ready)
-    return;
-  conf->turn.mode = tt_fwd;
-  conf->turn.gtkto = gtk_timeout_add(conf->turn.spd, tb_new_turn, conf);  
+    if ( !conf->ready )
+    {
+        return;
+    }
+    conf->turn.mode = tt_fwd;
+    conf->turn.gtkto = gtk_timeout_add(conf->turn.spd, tb_new_turn, conf);
 }
 
 static GtkWidget *create_the_toolbar(conf_t *conf)
 {
-  GtkWidget *table, *wid, *hbox, *frame;
+    GtkWidget *table, *wid, *hbox, *frame;
 
-  frame = create_frame("Commandes");
-  if (!conf->debug)
-    table = create_picture("logo.xpm", conf);
-  else
+    frame = create_frame("Commandes");
+    if ( !conf->debug )
     {
-      table = gtk_table_new(2, 3, FALSE);
-      gtk_widget_show(table);
-      
-      hbox = gtk_hbox_new(FALSE, 4);
-      gtk_widget_show(hbox);
-      gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 2, 0, 1);
-      
-      wid = create_xpm_button("pause.xpm", NULL, conf);
-      gtk_tooltips_set_tip(conf->tooltips, wid, 
-			   "Pause: Arrêter temporairement la simulation", "");
-      gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
-      gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_pause, conf);
-      wid = create_xpm_button("play.xpm", NULL, conf);
-      gtk_tooltips_set_tip(conf->tooltips, wid, 
-			   "Play: Tour suivant", "");
-      gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
-      gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_play, conf);
-      wid = create_xpm_button("step.xpm", NULL, conf);
-      gtk_tooltips_set_tip(conf->tooltips, wid, 
-			   "Step: Exécuter le nombre de tours spécifié", "");
-      gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
-      gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_step, conf);
-      wid = create_xpm_button("ffwd.xpm", NULL, conf);
-      gtk_tooltips_set_tip(conf->tooltips, wid, 
-			   "Ffwd: Lancer la simulation en continu", "");
-      gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
-      gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_ffwd, conf);
-      
-      gtk_table_attach(GTK_TABLE(table), 
-		       create_label("Vitesse (ms): "),
-		       0, 1, 1, 2, 0, GTK_FILL | GTK_EXPAND, 0, 0);
-      wid = create_hscale(1, 2000, &(conf->turn.spd));
-      gtk_tooltips_set_tip(conf->tooltips, wid, 
-			   "Délai entre deux tours (mode ffwd)", "");
-      gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 1, 2);
-      gtk_table_attach(GTK_TABLE(table), 
-		       create_label("Pas (tours): "),
-		       0, 1, 2, 3, 0, GTK_FILL | GTK_EXPAND, 0, 0);
-      wid = create_hscale(0, 200, &(conf->turn.nbt));
-      gtk_tooltips_set_tip(conf->tooltips, wid, 
-			   "Nombres de tours à sauter (mode step)", "");
-      gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 2, 3);
+        table = create_picture("logo.xpm", conf);
     }
-  gtk_container_add(GTK_CONTAINER(frame), table);
-  return frame;
+    else
+    {
+        table = gtk_table_new(2, 3, FALSE);
+        gtk_widget_show(table);
+
+        hbox = gtk_hbox_new(FALSE, 4);
+        gtk_widget_show(hbox);
+        gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 2, 0, 1);
+
+        wid = create_xpm_button("pause.xpm", NULL, conf);
+        gtk_tooltips_set_tip(conf->tooltips, wid,
+                             "Pause: Arr�ter temporairement la simulation", "");
+        gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
+        gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_pause, conf);
+        wid = create_xpm_button("play.xpm", NULL, conf);
+        gtk_tooltips_set_tip(conf->tooltips, wid,
+                             "Play: Tour suivant", "");
+        gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
+        gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_play, conf);
+        wid = create_xpm_button("step.xpm", NULL, conf);
+        gtk_tooltips_set_tip(conf->tooltips, wid,
+                             "Step: Ex�cuter le nombre de tours sp�cifi�", "");
+        gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
+        gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_step, conf);
+        wid = create_xpm_button("ffwd.xpm", NULL, conf);
+        gtk_tooltips_set_tip(conf->tooltips, wid,
+                             "Ffwd: Lancer la simulation en continu", "");
+        gtk_box_pack_start(GTK_BOX(hbox), wid, TRUE, TRUE, 5);
+        gtk_signal_connect(GTK_OBJECT(wid), "clicked", tb_ffwd, conf);
+
+        gtk_table_attach(GTK_TABLE(table),
+                         create_label("Vitesse (ms): "),
+                         0, 1, 1, 2, 0, GTK_FILL | GTK_EXPAND, 0, 0);
+        wid = create_hscale(1, 2000, &( conf->turn.spd ));
+        gtk_tooltips_set_tip(conf->tooltips, wid,
+                             "D�lai entre deux tours (mode ffwd)", "");
+        gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 1, 2);
+        gtk_table_attach(GTK_TABLE(table),
+                         create_label("Pas (tours): "),
+                         0, 1, 2, 3, 0, GTK_FILL | GTK_EXPAND, 0, 0);
+        wid = create_hscale(0, 200, &( conf->turn.nbt ));
+        gtk_tooltips_set_tip(conf->tooltips, wid,
+                             "Nombres de tours � sauter (mode step)", "");
+        gtk_table_attach_defaults(GTK_TABLE(table), wid, 1, 2, 2, 3);
+    }
+    gtk_container_add(GTK_CONTAINER(frame), table);
+    return frame;
 }
 
 static void display_sprite_changed(GtkWidget *t, conf_t *conf)
 {
-  conf->big_radar = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t));
-  gamearea_refresh(conf->main, conf);
+    conf->big_radar = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t));
+    gamearea_refresh(conf->main, conf);
 }
 
 static void display_pulse_changed(GtkWidget *t, conf_t *conf)
 {
-  conf->big_pulse = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t));
-  gamearea_refresh(conf->main, conf);
+    conf->big_pulse = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t));
+    gamearea_refresh(conf->main, conf);
 }
 
 static void zoom_ratio_changed(GtkWidget *t, conf_t *conf)
 {
-  scroll_bigmap(conf, conf->mini_center_x, conf->mini_center_y);
+    scroll_bigmap(conf, conf->mini_center_x, conf->mini_center_y);
 }
 
 static GtkWidget *create_zoom_ratio(conf_t *conf)
 {
-  GtkWidget *frame, *ratio, *vbox, *wid;
-  GtkAdjustment *adj;
-
-  frame = create_frame("Contrôle de la zone principal");
-  vbox = gtk_vbox_new(FALSE, 0);
-  gtk_widget_show(vbox);
-  ratio = create_hscale_float(0, 10, &(conf->log_big_zoom));
-  gtk_tooltips_set_tip(conf->tooltips, ratio, 
-		       "Niveau de zoom", 
-		       "");
-  adj = gtk_range_get_adjustment(GTK_RANGE(ratio));
-  gtk_signal_connect_after(GTK_OBJECT(adj), "value_changed", 
-			   zoom_ratio_changed, conf);
-  gtk_box_pack_start(GTK_BOX(vbox), ratio, TRUE, FALSE, 0);
-  wid = gtk_check_button_new_with_label("Mode radar");
-  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), FALSE);
-  gtk_signal_connect(GTK_OBJECT(wid), "toggled", display_sprite_changed,
-		     conf);
-  gtk_widget_show(wid);
-  gtk_box_pack_start(GTK_BOX(vbox), wid, TRUE, FALSE, 0);
-  wid = gtk_check_button_new_with_label("Affichage des zones de pulse");
-  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), TRUE);
-  gtk_signal_connect(GTK_OBJECT(wid), "toggled", display_pulse_changed,
-		     conf);
-  gtk_widget_show(wid);
-  gtk_box_pack_start(GTK_BOX(vbox), wid, TRUE, FALSE, 0);
-  gtk_container_add(GTK_CONTAINER(frame), vbox);
-  return frame;
+    GtkWidget *frame, *ratio, *vbox, *wid;
+    GtkAdjustment *adj;
+
+    frame = create_frame("Contr�le de la zone principal");
+    vbox = gtk_vbox_new(FALSE, 0);
+    gtk_widget_show(vbox);
+    ratio = create_hscale_float(0, 10, &( conf->log_big_zoom ));
+    gtk_tooltips_set_tip(conf->tooltips, ratio,
+                         "Niveau de zoom",
+                         "");
+    adj = gtk_range_get_adjustment(GTK_RANGE(ratio));
+    gtk_signal_connect_after(GTK_OBJECT(adj), "value_changed",
+                             zoom_ratio_changed, conf);
+    gtk_box_pack_start(GTK_BOX(vbox), ratio, TRUE, FALSE, 0);
+    wid = gtk_check_button_new_with_label("Mode radar");
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), FALSE);
+    gtk_signal_connect(GTK_OBJECT(wid), "toggled", display_sprite_changed,
+                       conf);
+    gtk_widget_show(wid);
+    gtk_box_pack_start(GTK_BOX(vbox), wid, TRUE, FALSE, 0);
+    wid = gtk_check_button_new_with_label("Affichage des zones de pulse");
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), TRUE);
+    gtk_signal_connect(GTK_OBJECT(wid), "toggled", display_pulse_changed,
+                       conf);
+    gtk_widget_show(wid);
+    gtk_box_pack_start(GTK_BOX(vbox), wid, TRUE, FALSE, 0);
+    gtk_container_add(GTK_CONTAINER(frame), vbox);
+    return frame;
 }
 
 GtkWidget *create_toolbar(conf_t *conf)
 {
-  GtkWidget *table, *wid;
-  
-  table = gtk_table_new(1, 4, FALSE);
-  wid = create_the_toolbar(conf);
-  gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 0, 1, 
-		   GTK_EXPAND | GTK_FILL, 0, 5, 0);
-  wid = create_players_list(conf);
-  gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 1, 2, 
-		   GTK_EXPAND | GTK_FILL, 0, 5, 0);
-  wid = create_mini_map(conf);
-  gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 2, 3, 0, 0, 0, 0);
-  wid = create_zoom_ratio(conf);
-  gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 3, 4,
-		   GTK_EXPAND | GTK_FILL, 0, 10, 0);
-  gtk_widget_show(table);
-  return table;
+    GtkWidget *table, *wid;
+
+    table = gtk_table_new(1, 4, FALSE);
+    wid = create_the_toolbar(conf);
+    gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 0, 1,
+                     GTK_EXPAND | GTK_FILL, 0, 5, 0);
+    wid = create_players_list(conf);
+    gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 1, 2,
+                     GTK_EXPAND | GTK_FILL, 0, 5, 0);
+    wid = create_mini_map(conf);
+    gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 2, 3, 0, 0, 0, 0);
+    wid = create_zoom_ratio(conf);
+    gtk_table_attach(GTK_TABLE(table), wid, 0, 1, 3, 4,
+                     GTK_EXPAND | GTK_FILL, 0, 10, 0);
+    gtk_widget_show(table);
+    return table;
 }

+ 13 - 0
gtkutil/CMakeLists.txt

@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(GtkUtils)
+
+set(TARGET gtkutil)
+
+set(TARGET_SOURCE_FILES callbacks.c clist.c create.c filesel.c)
+
+add_library(${TARGET} ${TARGET_SOURCE_FILES})
+
+target_compile_options(${TARGET} PRIVATE -rdynamic)
+
+install(TARGETS ${TARGET} RUNTIME DESTINATION "lib")

+ 0 - 7
gtkutil/Makefile.am

@@ -1,7 +0,0 @@
-# $Id: Makefile.am,v 1.1 2001/04/14 20:01:15 kilobug Exp $
-
-INCLUDES = @GTK_CFLAGS@
-
-noinst_LIBRARIES	  = libgtkutil.a
-libgtkutil_a_SOURCES	  = gtkutil.h callbacks.c create.c clist.c filesel.c
-libgtkutil_a_DEPENDENCIES = ../general.h

+ 15 - 13
gtkutil/callbacks.c

@@ -1,50 +1,52 @@
-/* $Id: callbacks.c,v 1.1 2001/04/14 20:01:15 kilobug Exp $ */
-
 #include "gtkutil.h"
 
 /* Destroy target widget */
 void destroy_widget(GtkWidget *w, gpointer data)
 {
-  gtk_widget_destroy(data);
+    gtk_widget_destroy(data);
 }
 
 /* Hide target widget */
 void hide_widget(GtkWidget *w, gpointer data)
 {
-  gtk_widget_hide(data);  
+    gtk_widget_hide(data);
 }
 
 /* Free target pointer */
 void free_callback(GtkObject *obj, void *data)
 {
-  if (data != NULL)
-    g_free(data);
+    if ( data != NULL )
+    {
+        g_free(data);
+    }
 }
 
 void set_data_from_entry(GtkWidget *w, char **data)
 {
-  if (*data != NULL)
-    g_free(*data);
-  *data = strdup(gtk_entry_get_text(GTK_ENTRY(w)));
+    if ( *data != NULL )
+    {
+        g_free(*data);
+    }
+    *data = strdup(gtk_entry_get_text(GTK_ENTRY(w)));
 }
 
 void set_data_from_toggle(GtkWidget *w, int *data)
 {
-  *data = (GTK_TOGGLE_BUTTON(w)->active);
+    *data = ( GTK_TOGGLE_BUTTON(w)->active );
 }
 
 void set_data_from_spin(GtkWidget *w, int *data)
 {
-  *data = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w));
+    *data = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w));
 }
 
 void set_data_from_adjustment(GtkAdjustment *adj, int *value)
 {
-  *value = adj->value;
+    *value = adj->value;
 }
 
 void set_data_from_adjustment_float(GtkAdjustment *adj, float *value)
 {
-  *value = adj->value;
+    *value = adj->value;
 }
 

+ 102 - 77
gtkutil/clist.c

@@ -1,107 +1,132 @@
-/* $Id: clist.c,v 1.4 2001/04/25 14:31:48 kilobug Exp $ */
-
 #include "gtkutil.h"
 
 static void list_click(GtkCList *clist, gint column, GtkSortType *sort)
 {
-  if (sort[0] == column)
-    sort[column + 1] = !sort[column + 1];
-  else
-    sort[0] = column;
-  gtk_clist_set_sort_type(clist, sort[column + 1]);
-  gtk_clist_set_sort_column(clist, column);
-  gtk_clist_sort(clist);
+    if ( sort[0] == column )
+    {
+        sort[column + 1] = !sort[column + 1];
+    }
+    else
+    {
+        sort[0] = column;
+    }
+    gtk_clist_set_sort_type(clist, sort[column + 1]);
+    gtk_clist_set_sort_column(clist, column);
+    gtk_clist_sort(clist);
 }
 
 GtkWidget *create_clist(int nbcol, int defsort, ...)
 {
-  char **titles;
-  GtkSortType *sort = NULL;
-  int i;
-  va_list va;
-  int *width;
-  GtkWidget *l;
+    char **titles;
+    GtkSortType *sort = NULL;
+    int i;
+    va_list va;
+    int *width;
+    GtkWidget *l;
+
+    if ( nbcol <= 0 )
+    {
+        return NULL;
+    }
 
-  if (nbcol <= 0)
-    return NULL;
+    titles = g_malloc(nbcol * sizeof(*titles));
+    va_start(va, defsort);
+    for ( i = 0 ; i < nbcol ; i++ )
+    {
+        titles[i] = va_arg(va,
+    }
+    char *);
+    width = g_malloc(nbcol * sizeof(*width));
+    for ( i = 0 ; i < nbcol ; i++ )
+    {
+        width[i] = va_arg(va,
+    }
+    int);
+    sort = g_malloc(( nbcol + 1 ) * sizeof(*sort));
+    for ( i = 0 ; i < nbcol ; i++ )
+    {
+        sort[i + 1] = va_arg(va, GtkSortType);
+    }
+    sort[0] = defsort;
 
-  titles = g_malloc(nbcol * sizeof(*titles));
-  va_start(va, defsort);
-  for (i = 0; i < nbcol; i++)
-    titles[i] = va_arg(va, char *);
-  width = g_malloc(nbcol * sizeof(*width));
-  for (i = 0; i < nbcol; i++)
-    width[i] = va_arg(va, int);
-  sort = g_malloc((nbcol + 1) * sizeof(*sort));
-  for (i = 0; i < nbcol; i++)
-    sort[i + 1] = va_arg(va, GtkSortType);
-  sort[0] = defsort;
-  
-  l = gtk_clist_new_with_titles(nbcol, titles);
-  g_free(titles);
-  gtk_clist_set_shadow_type(GTK_CLIST(l), GTK_SHADOW_IN);
-  gtk_clist_column_titles_active(GTK_CLIST(l));
-  for (i = 0; i < nbcol; i++)
-    gtk_clist_set_column_width(GTK_CLIST(l), i, width[i]);
-  g_free(width);
-  gtk_clist_set_auto_sort(GTK_CLIST(l), TRUE);
-  gtk_clist_set_sort_column(GTK_CLIST(l), sort[0]);
-  gtk_clist_set_sort_type(GTK_CLIST(l), sort[sort[0] + 1]);
-  gtk_signal_connect(GTK_OBJECT(l), "click-column", list_click, sort);
-  gtk_signal_connect_after(GTK_OBJECT(l), "destroy", free_callback, sort);
-  gtk_widget_show(l);
-  va_end(va);
-  return l;
+    l = gtk_clist_new_with_titles(nbcol, titles);
+    g_free(titles);
+    gtk_clist_set_shadow_type(GTK_CLIST(l), GTK_SHADOW_IN);
+    gtk_clist_column_titles_active(GTK_CLIST(l));
+    for ( i = 0 ; i < nbcol ; i++ )
+    {
+        gtk_clist_set_column_width(GTK_CLIST(l), i, width[i]);
+    }
+    g_free(width);
+    gtk_clist_set_auto_sort(GTK_CLIST(l), TRUE);
+    gtk_clist_set_sort_column(GTK_CLIST(l), sort[0]);
+    gtk_clist_set_sort_type(GTK_CLIST(l), sort[sort[0] + 1]);
+    gtk_signal_connect(GTK_OBJECT(l), "click-column", list_click, sort);
+    gtk_signal_connect_after(GTK_OBJECT(l), "destroy", free_callback, sort);
+    gtk_widget_show(l);
+    va_end(va);
+    return l;
 }
 
 static const char *clist_comp_get_str(GtkCList *clist, gconstpointer ptr)
 {
-  return ((GtkCListRow *) ptr)->cell[clist->sort_column].u.text;
+    return ((GtkCListRow *) ptr )->cell[clist->sort_column].u.text;
 }
 
 int clist_compare_str(GtkCList *clist, gconstpointer p1, gconstpointer p2)
 {
-  int i;  
-  const char *buf1, *buf2;
+    int i;
+    const char *buf1, *buf2;
 
-  buf1 = clist_comp_get_str(clist, p1);
-  buf2 = clist_comp_get_str(clist, p2);
-  i = g_strcasecmp(buf1, buf2);
-  if (i < 0)
-    i = -42;
-  if (i > 0)
-    i = 42;
-  return i;
+    buf1 = clist_comp_get_str(clist, p1);
+    buf2 = clist_comp_get_str(clist, p2);
+    i = g_strcasecmp(buf1, buf2);
+    if ( i < 0 )
+    {
+        i = -42;
+    }
+    if ( i > 0 )
+    {
+        i = 42;
+    }
+    return i;
 }
 
 int clist_compare_float(GtkCList *clist, gconstpointer p1, gconstpointer p2)
 {
-  int i;  
-  const char *buf1, *buf2;
+    int i;
+    const char *buf1, *buf2;
 
-  buf1 = clist_comp_get_str(clist, p1);
-  buf2 = clist_comp_get_str(clist, p2);
-  i = atoi(buf1) - atoi(buf2);
-  if (i < 0)
-    i = -42;
-  if (i > 0)
-    i = 42;
-  return i;
+    buf1 = clist_comp_get_str(clist, p1);
+    buf2 = clist_comp_get_str(clist, p2);
+    i = atoi(buf1) - atoi(buf2);
+    if ( i < 0 )
+    {
+        i = -42;
+    }
+    if ( i > 0 )
+    {
+        i = 42;
+    }
+    return i;
 }
 
 void clist_set_tooltips(GtkCList *clist, GtkTooltips *tt, ...)
 {
-  va_list va;
-  const char *s;
-  int i;
-  GtkWidget *wid;
+    va_list va;
+    const char *s;
+    int i;
+    GtkWidget *wid;
 
-  va_start(va, tt);
-  if ((clist != NULL) && (tt != NULL))
-    for (i = 0; (s = va_arg(va, const char *)) != NULL; i++)
-      {
-	wid = gtk_clist_get_column_widget(clist, i);
-	gtk_tooltips_set_tip(tt, wid->parent, s, ""); 
-      }
-  va_end(va);
+    va_start(va, tt);
+    if (( clist != NULL ) && ( tt != NULL ))
+    {
+        for ( i = 0 ; ( s = va_arg(va, const char *
+    })) != NULL;
+    i++)
+    {
+        wid = gtk_clist_get_column_widget(clist, i);
+        gtk_tooltips_set_tip(tt, wid->parent, s, "");
+    }
+    va_end(va);
 }

+ 112 - 106
gtkutil/create.c

@@ -1,5 +1,3 @@
-/* $Id: create.c,v 1.5 2001/04/25 14:31:48 kilobug Exp $ */
-
 #include "gtkutil.h"
 
 /*
@@ -7,138 +5,146 @@
 */
 GtkWidget *create_frame(const char *label)
 {
-  GtkWidget *widget;
-  
-  widget = gtk_frame_new(label);
-  gtk_frame_set_shadow_type(GTK_FRAME(widget), GTK_SHADOW_ETCHED_IN);
-  gtk_frame_set_label_align(GTK_FRAME(widget), 0.5, 0);
-  gtk_widget_show(widget);
-  return widget;
+    GtkWidget *widget;
+
+    widget = gtk_frame_new(label);
+    gtk_frame_set_shadow_type(GTK_FRAME(widget), GTK_SHADOW_ETCHED_IN);
+    gtk_frame_set_label_align(GTK_FRAME(widget), 0.5, 0);
+    gtk_widget_show(widget);
+    return widget;
 }
 
 GtkWidget *create_label(const char *label)
 {
-  GtkWidget *widget;
-  
-  widget = gtk_label_new(label);
-  gtk_widget_show(widget);
-  return widget;
+    GtkWidget *widget;
+
+    widget = gtk_label_new(label);
+    gtk_widget_show(widget);
+    return widget;
 }
 
 GtkWidget *create_hscale(int min, int max, int *value)
 {
-  GtkObject *adj;
-  GtkWidget *wid;
-
-  adj = gtk_adjustment_new(*value, min, max, 1, 10, 20);
-  wid = gtk_hscale_new(GTK_ADJUSTMENT(adj));
-  gtk_signal_connect(GTK_OBJECT(adj), "value_changed", 
-		     set_data_from_adjustment,  value);
-  gtk_scale_set_digits(GTK_SCALE(wid), 0);
-  gtk_widget_show(wid);  
-  return wid;
+    GtkObject *adj;
+    GtkWidget *wid;
+
+    adj = gtk_adjustment_new(*value, min, max, 1, 10, 20);
+    wid = gtk_hscale_new(GTK_ADJUSTMENT(adj));
+    gtk_signal_connect(GTK_OBJECT(adj), "value_changed",
+                       set_data_from_adjustment, value);
+    gtk_scale_set_digits(GTK_SCALE(wid), 0);
+    gtk_widget_show(wid);
+    return wid;
 }
 
 GtkWidget *create_hscale_float(float min, float max, float *value)
 {
-  GtkObject *adj;
-  GtkWidget *wid;
-
-  adj = gtk_adjustment_new(*value, min, max, 1, 2, 0);
-  wid = gtk_hscale_new(GTK_ADJUSTMENT(adj));
-  gtk_signal_connect(GTK_OBJECT(adj), "value_changed", 
-		     set_data_from_adjustment_float,  value);
-  gtk_scale_set_digits(GTK_SCALE(wid), 2);
-  gtk_widget_show(wid);  
-  return wid;
+    GtkObject *adj;
+    GtkWidget *wid;
+
+    adj = gtk_adjustment_new(*value, min, max, 1, 2, 0);
+    wid = gtk_hscale_new(GTK_ADJUSTMENT(adj));
+    gtk_signal_connect(GTK_OBJECT(adj), "value_changed",
+                       set_data_from_adjustment_float, value);
+    gtk_scale_set_digits(GTK_SCALE(wid), 2);
+    gtk_widget_show(wid);
+    return wid;
 }
 
-GtkWidget *create_dialog(const char *title, GtkWidget *main_area, 
-			 const char *msg1, const char *msg2,
-			 GtkSignalFunc callback, void *data,
-			 GtkSignalFunc destroy)
+GtkWidget *create_dialog(const char *title, GtkWidget *main_area,
+                         const char *msg1, const char *msg2,
+                         GtkSignalFunc callback, void *data,
+                         GtkSignalFunc destroy)
 {
-  GtkWidget *dialog, *hbox, *widget;
-  GtkAccelGroup *accel_group;
-
-  /* Main box */
-  dialog = gtk_dialog_new();
-  gtk_widget_hide(dialog);
-  gtk_signal_connect(GTK_OBJECT(dialog), "destroy", 
-		     GTK_SIGNAL_FUNC(destroy), dialog);
-  gtk_window_set_title(GTK_WINDOW(dialog), title);
-  gtk_container_set_border_width(GTK_CONTAINER(&(GTK_DIALOG(dialog)->window)),
-				 7);  
-  accel_group = gtk_accel_group_new();
-  gtk_window_add_accel_group(GTK_WINDOW(&(GTK_DIALOG(dialog)->window)), 
-			     accel_group);
-  
-  /* Buttons */
-  hbox = gtk_hbox_new(FALSE, 3);
-  gtk_widget_show(hbox);
-  if (msg1 != NULL)
+    GtkWidget *dialog, *hbox, *widget;
+    GtkAccelGroup *accel_group;
+
+    /* Main box */
+    dialog = gtk_dialog_new();
+    gtk_widget_hide(dialog);
+    gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
+                       GTK_SIGNAL_FUNC(destroy), dialog);
+    gtk_window_set_title(GTK_WINDOW(dialog), title);
+    gtk_container_set_border_width(GTK_CONTAINER(&( GTK_DIALOG(dialog)->window )),
+                                   7);
+    accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(&( GTK_DIALOG(dialog)->window )),
+                               accel_group);
+
+    /* Buttons */
+    hbox = gtk_hbox_new(FALSE, 3);
+    gtk_widget_show(hbox);
+    if ( msg1 != NULL )
     {
-      widget = gtk_button_new_with_label(msg1);
-      gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
-				 GTK_ACCEL_VISIBLE);
-      gtk_widget_show(widget);
-      gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-			 GTK_SIGNAL_FUNC(callback), data);
-      gtk_signal_connect_after(GTK_OBJECT(widget), "clicked", 
-			       GTK_SIGNAL_FUNC(destroy), dialog); 
-      gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+        widget = gtk_button_new_with_label(msg1);
+        gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
+                                   GTK_ACCEL_VISIBLE);
+        gtk_widget_show(widget);
+        gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                           GTK_SIGNAL_FUNC(callback), data);
+        gtk_signal_connect_after(GTK_OBJECT(widget), "clicked",
+                                 GTK_SIGNAL_FUNC(destroy), dialog);
+        gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
     }
-  widget = gtk_button_new_with_label(msg2);
-  gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Escape, 0,
-                              GTK_ACCEL_VISIBLE);
-  if (callback == NULL)
-    gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
-			       GTK_ACCEL_VISIBLE);
-  gtk_widget_show(widget);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(destroy), dialog); 
-  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), hbox, TRUE,
-		     TRUE, 9);
-
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), main_area, TRUE,
-		     TRUE, 9);
-  return dialog;
+    widget = gtk_button_new_with_label(msg2);
+    gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Escape, 0,
+                               GTK_ACCEL_VISIBLE);
+    if ( callback == NULL )
+    {
+        gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
+                                   GTK_ACCEL_VISIBLE);
+    }
+    gtk_widget_show(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(destroy), dialog);
+    gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), hbox, TRUE,
+                       TRUE, 9);
+
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), main_area, TRUE,
+                       TRUE, 9);
+    return dialog;
 }
 
 GtkWidget *create_spin(int min, int max, int def)
 {
-  GtkAdjustment *adj;
-  GtkWidget *result;
-
-  adj = (GtkAdjustment *)gtk_adjustment_new(def, min, max, 1, 10, 0);
-  result = gtk_spin_button_new(adj, 0.4, 0);
-  gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(result), TRUE);
-  gtk_widget_show(result);
-  return result;
+    GtkAdjustment *adj;
+    GtkWidget *result;
+
+    adj = (GtkAdjustment *) gtk_adjustment_new(def, min, max, 1, 10, 0);
+    result = gtk_spin_button_new(adj, 0.4, 0);
+    gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(result), TRUE);
+    gtk_widget_show(result);
+    return result;
 }
 
 GtkWidget *create_entry(const char *def, int len)
 {
-  GtkWidget *result;
-
-  if (len > 0)
-    result = gtk_entry_new_with_max_length(len);
-  else
-    result = gtk_entry_new();
-  if (def != NULL)
-    gtk_entry_set_text(GTK_ENTRY(result), def);
-  gtk_widget_show(result);
-  return result;
+    GtkWidget *result;
+
+    if ( len > 0 )
+    {
+        result = gtk_entry_new_with_max_length(len);
+    }
+    else
+    {
+        result = gtk_entry_new();
+    }
+    if ( def != NULL )
+    {
+        gtk_entry_set_text(GTK_ENTRY(result), def);
+    }
+    gtk_widget_show(result);
+    return result;
 }
 
-GtkWidget *create_check(gboolean def)
+GtkWidget *create_check(bool def)
 {
-  GtkWidget *result;
+    GtkWidget *result;
 
-  result = gtk_check_button_new();
-  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(result), def);
-  gtk_widget_show(result);
-  return result;
+    result = gtk_check_button_new();
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(result), def);
+    gtk_widget_show(result);
+    return result;
 }
 

+ 32 - 32
gtkutil/filesel.c

@@ -1,50 +1,50 @@
-/* $Id: filesel.c,v 1.1 2001/04/14 20:01:15 kilobug Exp $ */
-
 #include "gtkutil.h"
 
 typedef struct _filesel_t
 {
-  GtkEntry *entry;
-  GtkWidget *filesel;
+    GtkEntry *entry;
+    GtkWidget *filesel;
 } filesel_t;
 
 static void clean_filesel(GtkWidget *wid, filesel_t *file)
 {
-  if (file->filesel != NULL)
-    gtk_widget_destroy(file->filesel);
-  g_free(file);
+    if ( file->filesel != NULL )
+    {
+        gtk_widget_destroy(file->filesel);
+    }
+    g_free(file);
 }
 
 static void ok_filesel(GtkWidget *wid, filesel_t *file)
 {
-  char *s;
+    char *s;
 
-  s = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file->filesel));
-  gtk_entry_set_text(file->entry, s);
-  gtk_widget_hide(file->filesel);
+    s = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file->filesel));
+    gtk_entry_set_text(file->entry, s);
+    gtk_widget_hide(file->filesel);
 }
 
-GtkWidget *create_filesel_button(const char *label, const char *title, 
-				 GtkEntry *entry)
+GtkWidget *create_filesel_button(const char *label, const char *title,
+                                 GtkEntry *entry)
 {
-  GtkWidget *button;
-  filesel_t *file;
-  GtkFileSelection *fs;
+    GtkWidget *button;
+    filesel_t *file;
+    GtkFileSelection *fs;
 
-  file = g_malloc(sizeof(*file));
-  file->entry = entry;
-  file->filesel = gtk_file_selection_new(title);
-  gtk_widget_hide(file->filesel);
-  fs = GTK_FILE_SELECTION(file->filesel);
-  gtk_file_selection_hide_fileop_buttons(fs);
-  gtk_signal_connect_object(GTK_OBJECT(fs->cancel_button), "clicked", 
-			    gtk_widget_hide, GTK_OBJECT(file->filesel));
-  gtk_signal_connect(GTK_OBJECT(fs->ok_button), "clicked", ok_filesel, file);
-  button = gtk_button_new_with_label(label);
-  gtk_signal_connect_object(GTK_OBJECT(button), "clicked", 
-			    gtk_widget_show, GTK_OBJECT(file->filesel));
-  gtk_signal_connect_after(GTK_OBJECT(button), "destroy", 
-			   clean_filesel, file);
-  gtk_widget_show(button);
-  return button;
+    file = g_malloc(sizeof(*file));
+    file->entry = entry;
+    file->filesel = gtk_file_selection_new(title);
+    gtk_widget_hide(file->filesel);
+    fs = GTK_FILE_SELECTION(file->filesel);
+    gtk_file_selection_hide_fileop_buttons(fs);
+    gtk_signal_connect_object(GTK_OBJECT(fs->cancel_button), "clicked",
+                              gtk_widget_hide, GTK_OBJECT(file->filesel));
+    gtk_signal_connect(GTK_OBJECT(fs->ok_button), "clicked", ok_filesel, file);
+    button = gtk_button_new_with_label(label);
+    gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
+                              gtk_widget_show, GTK_OBJECT(file->filesel));
+    gtk_signal_connect_after(GTK_OBJECT(button), "destroy",
+                             clean_filesel, file);
+    gtk_widget_show(button);
+    return button;
 }

+ 1 - 1
include/client/c++/prolo.hh

@@ -1,4 +1,4 @@
-/* $Id: prolo.hh,v 1.3 2001/05/04 10:29:38 glop Exp $ */
+
 
 #ifndef __INTERFACE_CPP_H__
 #define __INTERFACE_CPP_H__

+ 1 - 1
include/client/c/prolo.h

@@ -1,4 +1,4 @@
-/* $Id: prolo.h,v 1.12 2001/05/04 10:29:35 glop Exp $ */
+
 
 #ifndef __INTERFACE_C_H__
 #define __INTERFACE_C_H__

+ 1 - 1
include/client/cpp/prolo.hh

@@ -1,4 +1,4 @@
-/* $Id: prolo.hh,v 1.10 2001/05/04 10:29:44 glop Exp $ */
+
 
 #ifndef __PROLO_BITMAP_H__
 #define __PROLO_BITMAP_H__

+ 0 - 2
include/general.h

@@ -1,5 +1,3 @@
-/* $Id: general.h,v 1.11 2001/04/30 16:02:05 kilobug Exp $ */
-
 #ifndef __PROLO_GENERAL_H__
 #define __PROLO_GENERAL_H__
 

+ 25 - 9
include/gtkutil.h

@@ -1,5 +1,3 @@
-/* $Id: gtkutil.h,v 1.3 2001/04/19 08:33:44 kilobug Exp $ */
-
 #ifndef __LIB_GTK_UTIL_H__
 #define __LIB_GTK_UTIL_H__
 
@@ -10,33 +8,51 @@
 
 /* General callbacks */
 void destroy_widget(GtkWidget *w, gpointer data);
+
 void hide_widget(GtkWidget *w, gpointer data);
+
 void set_data_from_entry(GtkWidget *w, char **data);
+
 void set_data_from_toggle(GtkWidget *w, int *data);
+
 void set_data_from_spin(GtkWidget *w, int *data);
+
 void set_data_from_adjustment(GtkAdjustment *adj, int *value);
+
 void set_data_from_adjustment_float(GtkAdjustment *adj, float *value);
+
 void free_callback(GtkObject *obj, void *data);
 
 /* General creators */
 GtkWidget *create_frame(const char *label);
+
 GtkWidget *create_label(const char *label);
+
 GtkWidget *create_hscale(int min, int max, int *value);
+
 GtkWidget *create_hscale_float(float min, float max, float *value);
+
 GtkWidget *create_clist(int nbcol, int defsort, ...);
+
 GtkWidget *create_spin(int min, int max, int def);
-GtkWidget *create_check(gboolean def);
+
+GtkWidget *create_check(bool def);
+
 GtkWidget *create_entry(const char *def, int len);
-GtkWidget *create_dialog(const char *title, GtkWidget *main_area, 
-			 const char *msg1, const char *msg2,
-			 GtkSignalFunc callback, void *data,
-			 GtkSignalFunc destroy);
-GtkWidget *create_filesel_button(const char *label, const char *title, 
-				 GtkEntry *entry);
+
+GtkWidget *create_dialog(const char *title, GtkWidget *main_area,
+                         const char *msg1, const char *msg2,
+                         GtkSignalFunc callback, void *data,
+                         GtkSignalFunc destroy);
+
+GtkWidget *create_filesel_button(const char *label, const char *title,
+                                 GtkEntry *entry);
 
 /* Special */
 int clist_compare_str(GtkCList *clist, gconstpointer p1, gconstpointer p2);
+
 int clist_compare_float(GtkCList *clist, gconstpointer p1, gconstpointer p2);
+
 void clist_set_tooltips(GtkCList *clist, GtkTooltips *tt, ...);
 
 #endif

+ 38 - 16
include/pulsarnet.h

@@ -1,57 +1,79 @@
-/* $Id: net.h,v 1.8 2001/04/28 15:29:25 kilobug Exp $ */
-
 #ifndef __PROLO_NET_LIB_H__
 #define __PROLO_NET_LIB_H__
 
+#include <stdio.h>
+
+#include <stdbool.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
-#include "../general.h"
-#include <glib.h>
+#include <general.h>
 
 #define PROTOCOL_VERSION 0x4207
 
-typedef enum { net_type_int = 0x03, net_type_float = 0x0B, 
-	       net_type_char = 0x30, net_type_str = 0xB0,
-               net_type_none = 0x33 } net_type_t;
+typedef enum
+{
+    net_type_int = 0x03, net_type_float = 0x0B,
+    net_type_char = 0x30, net_type_str = 0xB0,
+    net_type_none = 0x33
+} net_type_t;
+
 typedef void (net_error_hdlr_t)(net_type_t get, net_type_t wanted, void *data);
 
 /* Error handlers */
 void net_set_error_handler(net_error_hdlr_t *hdlr, void *data);
+
 net_error_hdlr_t net_error_abort;
 net_error_hdlr_t net_error_ignore;
+
 const char *net_type_name(net_type_t t);
 
 /* Opening sockets */
 int net_connect_to(const char *host, int port, char *err, int errsz,
-		   struct timeval *to);
+                   struct timeval *to);
+
 int net_listen_at(int port, int max_con, char *err, int errsz);
 
 /* Writing data */
 void net_wr_string(FILE *file, const char *s);
+
 void net_wr_int(FILE *file, int val);
-void net_wr_flag(FILE *file, gboolean val);
+
+void net_wr_flag(FILE *file, bool val);
+
 void net_wr_char(FILE *file, char c);
+
 void net_wr_float(FILE *file, float f);
 
 /* Reading data */
 char *net_get_string(int fd);
+
 int net_get_int(int fd);
-gboolean net_get_flag(int fd);
+
+bool net_get_flag(int fd);
+
 char net_get_char(int fd);
+
 float net_get_float(int fd);
 
 /* Checking values */
-gboolean net_chk_string(int fd, const char *s);
-gboolean net_chk_int(int fd, int val);
-gboolean net_chk_flag(int fd, gboolean val);
-gboolean net_chk_char(int fd, char c);
-gboolean net_chk_float(int fd, float f);
+bool net_chk_string(int fd, const char *s);
+
+bool net_chk_int(int fd, int val);
+
+bool net_chk_flag(int fd, bool val);
+
+bool net_chk_char(int fd, char c);
+
+bool net_chk_float(int fd, float f);
+
 int net_chk_str_list(int fd, ...); /* -1 = not in list */
 
 /* Ack */
-gboolean net_wait_ack(int fd);
+bool net_wait_ack(int fd);
+
 void net_send_ack(FILE *file);
+
 void net_send_abort(FILE *file);
 
 #endif

+ 18 - 0
meta-client/CMakeLists.txt

@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(MetaClient)
+
+find_package(CJSON REQUIRED)
+
+set(TARGET metaclient)
+
+set(TARGET_HEADER_FILES include/mclient.h include/mysql.h include/tournois.h)
+set(TARGET_SOURCE_FILES bitmaps.c gtk_main.c init.c main.c maps.c matchs.c menubar.c mysql.c mysql_list.c run_match.c
+        run_tournois.c tournois.c)
+
+add_executable(${TARGET} ${TARGET_SOURCE_FILES} ${TARGET_HEADER_FILES})
+
+target_compile_options(${TARGET} PRIVATE -rdynamic)
+target_link_libraries(${TARGET} pulsarnet gtkutil)
+
+install(TARGETS ${TARGET} RUNTIME DESTINATION "bin")

+ 0 - 14
meta-client/Makefile.am

@@ -1,14 +0,0 @@
-# $Id: Makefile.am,v 1.8 2001/05/03 23:17:47 kilobug Exp $
-
-INCLUDES = @GTK_CFLAGS@
-
-bin_PROGRAMS		= prologin
-prologin_SOURCES	= init.c main.c mclient.h \
-			  gtk_main.c menubar.c \
-			  bitmaps.c maps.c champions.c \
-		   	  run_match.c matchs.c \
-			  tournois.c tournois.h run_tournois.c \
-		          mysql.h mysql_list.c mysql.c
-prologin_LDADD		= @GTK_LIBS@ -lmysqlclient -L../gtkutil -lgtkutil
-prologin_DEPENDENCIES	= ../gtkutil/libgtkutil.a
-

+ 89 - 83
meta-client/bitmaps.c

@@ -1,147 +1,153 @@
-/* $Id: bitmaps.c,v 1.5 2001/04/25 16:37:21 kilobug Exp $ */
-
 #include "mclient.h"
 
 #define SEND_MESSAGE "ns_send_msg"
 
 typedef struct _msg_t
 {
-  GSList *recv;
-  GtkWidget *dialog;
-  GtkWidget *entry;
+    GSList *recv;
+    GtkWidget *dialog;
+    GtkWidget *entry;
 } msg_t;
 
 
 static void bmp_msg_do_send(GtkWidget *wid, msg_t *msg)
 {
-  GSList *l;
-  char buf[MYSQL_BUFFER_SIZE];
+    GSList *l;
+    char buf[MYSQL_BUFFER_SIZE];
 
-  for (l = msg->recv; l != NULL; l = l->next)
+    for ( l = msg->recv ; l != NULL ; l = l->next )
     {
-      g_snprintf(buf, MYSQL_BUFFER_SIZE, "%s %s '%s'",
-		 SEND_MESSAGE, (char *) l->data, 
-		 gtk_entry_get_text(GTK_ENTRY(msg->entry)));
-      system(buf);
+        g_snprintf(buf, MYSQL_BUFFER_SIZE, "%s %s '%s'",
+                   SEND_MESSAGE, (char *) l->data,
+                   gtk_entry_get_text(GTK_ENTRY(msg->entry)));
+        system(buf);
     }
 }
 
 static void bmp_msg_free(msg_t *msg)
 {
-  GSList *l;
+    GSList *l;
 
-  for (l = msg->recv; l != NULL; l = l->next)
-    g_free(l->data);
-  g_slist_free(msg->recv);
-  g_free(msg);
+    for ( l = msg->recv ; l != NULL ; l = l->next )
+    {
+        g_free(l->data);
+    }
+    g_slist_free(msg->recv);
+    g_free(msg);
 }
 
 void bmp_send_message(GtkWidget *wid, void *data)
 {
-  GList *bmps, *l;
-  msg_t *msg;
-  int id;
-
-  bmps = GTK_CLIST(gl_config->bmpl)->selection;
-  if (bmps == NULL)
-    return;
-  msg = g_malloc(sizeof(*msg));
-  for (msg->recv = NULL, l = bmps; l != NULL; l = l->next)
+    GList *bmps, *l;
+    msg_t *msg;
+    int id;
+
+    bmps = GTK_CLIST(gl_config->bmpl)->selection;
+    if ( bmps == NULL )
+    {
+        return;
+    }
+    msg = g_malloc(sizeof(*msg));
+    for ( msg->recv = NULL, l = bmps ; l != NULL ; l = l->next )
     {
-      id = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->bmpl), 
-					    GPOINTER_TO_INT(l->data)));
-      msg->recv = g_slist_prepend(msg->recv, 
-				  mysql_get_str(gl_config->mysql,
-						"SELECT login FROM Bitmaps "
-						"WHERE id=%d", id));
+        id = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->bmpl),
+                                              GPOINTER_TO_INT(l->data)));
+        msg->recv = g_slist_prepend(msg->recv,
+                                    mysql_get_str(gl_config->mysql,
+                                                  "SELECT login FROM Bitmaps "
+                                                  "WHERE id=%d", id));
     }
-  msg->entry = create_entry("", 200);
-  msg->dialog = create_dialog("Envoyer un message", msg->entry,
-			      "Envoyer", "Annuler", bmp_msg_do_send,
-			      msg, destroy_widget);
-  gtk_object_set_data_full(GTK_OBJECT(msg->dialog), "42", msg, 
-			   (GtkDestroyNotify) bmp_msg_free);
-  gtk_signal_connect(GTK_OBJECT(msg->entry), "activate", 
-		     bmp_msg_do_send, msg);
-  gtk_signal_connect_after(GTK_OBJECT(msg->entry), "activate", 
-			   destroy_widget, msg->dialog);
-  gtk_widget_show(msg->dialog);
+    msg->entry = create_entry("", 200);
+    msg->dialog = create_dialog("Envoyer un message", msg->entry,
+                                "Envoyer", "Annuler", bmp_msg_do_send,
+                                msg, destroy_widget);
+    gtk_object_set_data_full(GTK_OBJECT(msg->dialog), "42", msg,
+                             (GtkDestroyNotify) bmp_msg_free);
+    gtk_signal_connect(GTK_OBJECT(msg->entry), "activate",
+                       bmp_msg_do_send, msg);
+    gtk_signal_connect_after(GTK_OBJECT(msg->entry), "activate",
+                             destroy_widget, msg->dialog);
+    gtk_widget_show(msg->dialog);
 }
 
 int bmp_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
-  return clist_compare_str(clist, ptr1, ptr2);
+    return clist_compare_str(clist, ptr1, ptr2);
 }
 
 static char *bmp_statut(const char *val, void *data)
 {
-  switch (atoi(val))
+    switch ( atoi(val))
     {
     case STATUT_ABSENT:
-      return "Absent";
+        return "Absent";
     case STATUT_PRESENT:
-      return "Présent";
+        return "Pr�sent";
     case STATUT_ZLOCKE:
-      return "Zlocké";
+        return "Zlock�";
     }
-  return "Inconnu";
+    return "Inconnu";
 }
 
 static char *bmp_type(const char *val, void *data)
 {
-  switch (atoi(val))
+    switch ( atoi(val))
     {
     case 0:
-      return "Bitmap";
+        return "Bitmap";
     default:
-      return "Organisateur";
+        return "Organisateur";
     }
 }
 
-static const char *bmp_colors[] = 
-{ "#900000", "#009000", "#000090",
-  "#FF0000", "#00FF00", "#0000FF" };
+static const char *bmp_colors[] =
+        { "#900000", "#009000", "#000090",
+          "#FF0000", "#00FF00", "#0000FF" };
 
 static GdkColor *bmp_color(const sql_list_t *l, int id, void *data)
 {
-  GdkColor *col = NULL;
-  int i;
-
-  if (mysql_get_int(gl_config->mysql, 
-		    "SELECT staff FROM Bitmaps WHERE id=%d", id))
-    i = 3;
-  else 
-    i = 0;
-  switch (mysql_get_int(gl_config->mysql, 
-			"SELECT statut FROM Bitmaps WHERE id=%d", id))
+    GdkColor *col = NULL;
+    int i;
+
+    if ( mysql_get_int(gl_config->mysql,
+                       "SELECT staff FROM Bitmaps WHERE id=%d", id))
+    {
+        i = 3;
+    }
+    else
+    {
+        i = 0;
+    }
+    switch ( mysql_get_int(gl_config->mysql,
+                           "SELECT statut FROM Bitmaps WHERE id=%d", id))
     {
     case STATUT_ABSENT:
-      i += 0;
-      break;
+        i += 0;
+        break;
     case STATUT_ZLOCKE:
-      i += 1;
-      break;
+        i += 1;
+        break;
     case STATUT_PRESENT:
-      i += 2;
-      break;
+        i += 2;
+        break;
     }
-  col = g_malloc(sizeof(*col));
-  gdk_color_parse(bmp_colors[i], col);
-  gdk_color_alloc(gdk_colormap_get_system(), col);
-  return col;
+    col = g_malloc(sizeof(*col));
+    gdk_color_parse(bmp_colors[i], col);
+    gdk_color_alloc(gdk_colormap_get_system(), col);
+    return col;
 }
 
 void bmp_refresh(GtkWidget *wid, void *data)
 {
-  static sql_list_t *lst = NULL;
+    static sql_list_t *lst = NULL;
 
-  if (lst == NULL)
+    if ( lst == NULL )
     {
-      lst = mysql_list_make("SELECT * FROM Bitmaps WHERE 1",
-			    8, GTK_CLIST(gl_config->bmpl),
-			    6, bmp_statut, NULL, NULL,
-			    7, bmp_type, NULL, NULL, -1);
-      mysql_list_set_color_func(lst, bmp_color, NULL);
+        lst = mysql_list_make("SELECT * FROM Bitmaps WHERE 1",
+                              8, GTK_CLIST(gl_config->bmpl),
+                              6, bmp_statut, NULL, NULL,
+                              7, bmp_type, NULL, NULL, -1);
+        mysql_list_set_color_func(lst, bmp_color, NULL);
     }
-  mysql_list_refresh(lst, NULL);
+    mysql_list_refresh(lst, NULL);
 }

+ 38 - 35
meta-client/champions.c

@@ -1,68 +1,71 @@
-/* $Id: champions.c,v 1.10 2001/05/07 02:41:36 kilobug Exp $ */
-
 #include "mclient.h"
 
 int prg_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
-  switch (clist->sort_column)
+    switch ( clist->sort_column )
     {
-    case 0: case 1: case 4:
-      return clist_compare_str(clist, ptr1, ptr2);
-    case 2: case 3:
-      return clist_compare_float(clist, ptr1, ptr2);
+    case 0:
+    case 1:
+    case 4:
+        return clist_compare_str(clist, ptr1, ptr2);
+    case 2:
+    case 3:
+        return clist_compare_float(clist, ptr1, ptr2);
     }
-  return 0;
+    return 0;
 }
 
 static GdkColor *prg_color(const sql_list_t *l, int id, void *data)
 {
-  GdkColor *col = NULL;
-  int auteur;
+    GdkColor *col = NULL;
+    int auteur;
 
-  auteur = mysql_get_int(gl_config->mysql, 
-			 "SELECT auteur FROM Champions WHERE id=%d", id);
-  if (auteur == getuid())
+    auteur = mysql_get_int(gl_config->mysql,
+                           "SELECT auteur FROM Champions WHERE id=%d", id);
+    if ( auteur == getuid())
+    {
+        col = g_malloc(sizeof(*col));
+        gdk_color_parse("#009000", col);
+    }
+    if ( col != NULL )
     {
-      col = g_malloc(sizeof(*col));
-      gdk_color_parse("#009000", col);
+        gdk_color_alloc(gdk_colormap_get_system(), col);
     }
-  if (col != NULL)
-    gdk_color_alloc(gdk_colormap_get_system(), col);
-  return col;
+    return col;
 }
 
 void prg_refresh(GtkWidget *wid, void *data)
 {
-  static sql_list_t *lst = NULL;
-  char *buf;
+    static sql_list_t *lst = NULL;
+    char *buf;
 
-  if (lst == NULL)
+    if ( lst == NULL )
     {
-      buf = g_malloc(MYSQL_BUFFER_SIZE);
-      g_snprintf(buf, MYSQL_BUFFER_SIZE,
-		 "SELECT c.id, c.nom, b.pseudo, c.best, c.score, m.msg "
-		 "FROM   Champions c, Bitmaps b, Msg m "
-		 "WHERE  (c.auteur = b.id) AND (c.actif) AND (m.id = c.tourn)"
-		 "  AND  ((c.public) OR (c.auteur = %d) OR (%d = 1))",
-		 getuid(), gl_config->staff);
-      lst = mysql_list_make(buf, 6, GTK_CLIST(gl_config->prgl), -1);
-      mysql_list_set_color_func(lst, prg_color, NULL);
+        buf = g_malloc(MYSQL_BUFFER_SIZE);
+        g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                   "SELECT c.id, c.nom, b.pseudo, c.best, c.score, m.msg "
+                   "FROM   Champions c, Bitmaps b, Msg m "
+                   "WHERE  (c.auteur = b.id) AND (c.actif) AND (m.id = c.tourn)"
+                   "  AND  ((c.public) OR (c.auteur = %d) OR (%d = 1))",
+                   getuid(), gl_config->staff);
+        lst = mysql_list_make(buf, 6, GTK_CLIST(gl_config->prgl), -1);
+        mysql_list_set_color_func(lst, prg_color, NULL);
     }
-  mysql_list_refresh(lst, NULL);
+    mysql_list_refresh(lst, NULL);
 }
 
 void prg_add(GtkWidget *wid, void *data)
 {
-  gtk_widget_show(gl_config->prga->widget);
+    gtk_widget_show(gl_config->prga->widget);
 }
 
 void prg_remove(GtkWidget *wid, void *data)
 {
-  mysql_list_remove("Champions", GTK_CLIST(gl_config->prgl), prg_refresh);
+    mysql_list_remove("Champions", GTK_CLIST(gl_config->prgl), prg_refresh);
 }
 
 void prg_edit(GtkWidget *wid, void *data)
 {
-  mysql_list_edit("Modification d'un champion", GTK_CLIST(gl_config->prgl), 
-		  gl_config->prga, prg_refresh);
+    mysql_list_edit("Modification d'un champion", GTK_CLIST(gl_config->prgl),
+                    gl_config->prga, prg_refresh);
 }

+ 187 - 185
meta-client/gtk_main.c

@@ -1,204 +1,206 @@
-/* $Id: gtk_main.c,v 1.14 2001/05/07 02:41:36 kilobug Exp $ */
-
 #include "mclient.h"
 
 static void switch_page(GtkNotebook *notebook, GtkNotebookPage *foo,
-			int page, void *data)
+                        int page, void *data)
 {
-  if (gl_config->menunb[page] == NULL)
-    return;
-  gtk_signal_handler_block_by_func(GTK_OBJECT(notebook), 
-				   GTK_SIGNAL_FUNC(switch_page), data);
-  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gl_config->menunb[page]),
-				 TRUE);
-  gtk_signal_handler_unblock_by_func(GTK_OBJECT(notebook), 
-				     GTK_SIGNAL_FUNC(switch_page), data);
+    if ( gl_config->menunb[page] == NULL )
+    {
+        return;
+    }
+    gtk_signal_handler_block_by_func(GTK_OBJECT(notebook),
+                                     GTK_SIGNAL_FUNC(switch_page), data);
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gl_config->menunb[page]),
+                                   TRUE);
+    gtk_signal_handler_unblock_by_func(GTK_OBJECT(notebook),
+                                       GTK_SIGNAL_FUNC(switch_page), data);
 }
 
 static void create_page(GtkWidget *noteb, GtkWidget *inside, const char *label,
-			int nb, ...)
+                        int nb, ...)
 {
-  GtkWidget *hbox, *vbox, *but, *lab, *scroll;
-  va_list va;
-  int i;
-  
-  va_start(va, nb);
-  hbox = gtk_hbox_new(TRUE, 5);
-  for (i = 0; i < nb; i++)
+    GtkWidget *hbox, *vbox, *but, *lab, *scroll;
+    va_list va;
+    int i;
+
+    va_start(va, nb);
+    hbox = gtk_hbox_new(TRUE, 5);
+    for ( i = 0 ; i < nb ; i++ )
     {
-      but = gtk_button_new_with_label(va_arg(va, const char *));
-      gtk_widget_show(but);
-      gtk_tooltips_set_tip(gl_config->tooltips, but, 
-			   va_arg(va, const char *), "");
-      gtk_signal_connect(GTK_OBJECT(but), "clicked", 
-			 va_arg(va, GtkSignalFunc), NULL);
-      gtk_box_pack_start(GTK_BOX(hbox), but, TRUE, FALSE, 5);
+        but = gtk_button_new_with_label(va_arg(va,
+        const char *));
+        gtk_widget_show(but);
+        gtk_tooltips_set_tip(gl_config->tooltips, but,
+                             va_arg(va,
+        const char *), "");
+        gtk_signal_connect(GTK_OBJECT(but), "clicked",
+                           va_arg(va, GtkSignalFunc), NULL);
+        gtk_box_pack_start(GTK_BOX(hbox), but, TRUE, FALSE, 5);
     }
-  gtk_widget_show(hbox);
-
-  vbox = gtk_vbox_new(FALSE, 0);
-  scroll = gtk_scrolled_window_new(NULL, NULL);
-  gtk_widget_show(scroll);
-  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), 
-				 GTK_POLICY_AUTOMATIC,
-				 GTK_POLICY_AUTOMATIC);
-  gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
-  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
-  gtk_container_add(GTK_CONTAINER(scroll), inside);
-  gtk_widget_show(vbox);
-  lab = create_label(label);  
-  gtk_notebook_append_page_menu(GTK_NOTEBOOK(noteb), vbox, 
-				lab, create_label(label));
+    gtk_widget_show(hbox);
+
+    vbox = gtk_vbox_new(FALSE, 0);
+    scroll = gtk_scrolled_window_new(NULL, NULL);
+    gtk_widget_show(scroll);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+    gtk_container_add(GTK_CONTAINER(scroll), inside);
+    gtk_widget_show(vbox);
+    lab = create_label(label);
+    gtk_notebook_append_page_menu(GTK_NOTEBOOK(noteb), vbox,
+                                  lab, create_label(label));
 }
 
 static GtkWidget *create_main_area()
 {
-  GtkWidget *widget;
-
-  widget = gtk_notebook_new();
-  gl_config->notebook = GTK_NOTEBOOK(widget);
-  gtk_notebook_popup_enable(gl_config->notebook);
-  gtk_notebook_set_homogeneous_tabs(gl_config->notebook, TRUE);
-  gtk_widget_show(widget);
-  gtk_signal_connect(GTK_OBJECT(widget), "switch-page", switch_page, NULL);
-  gl_config->bmpl = create_clist(7, 0,
-				 "Login", "Nom", "Prénom", "Pseudo", 
-				 "Machine", "Statut", "Type",
-				 50, 110, 110, 90, 60, 60, 60,
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING);
-  gtk_clist_set_compare_func(GTK_CLIST(gl_config->bmpl), bmp_sort);
-  clist_set_tooltips(GTK_CLIST(gl_config->bmpl), gl_config->tooltips,
-		     "Trier par login", "Trier par nom", "Trier par prénom",
-		     "Trier par pseudo", "Trier par machine", 
-		     "Trier par satut", "Séparer les orgas des bitmaps", NULL);
-		     
-  create_page(widget, gl_config->bmpl, "Personnes", 2,
-	      " Actualiser ", "Réactualiser la liste", bmp_refresh,
-	      " Ecrire ", "Envoyer un message", bmp_send_message);
-  gtk_clist_set_selection_mode(GTK_CLIST(gl_config->bmpl), 
-			       GTK_SELECTION_EXTENDED);
-
-  gl_config->mapl = create_clist(5, 0, 
-				 "Nom", "Description", "Joueurs", 
-				 "Auteur", "Taille",
-				 80, 150, 50, 50, 50,
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING);
-  create_page(widget, gl_config->mapl, "Cartes", 4,
-	      " Actualiser ", "Réactualiser la liste", map_refresh, 
-	      " Ajouter ", "Ajouter une carte perso", map_add, 
-	      " Modifier ", "Modifier une carte", map_edit,
-	      " Supprimer ", "Supprimer la carte sélectionnée", map_remove);
-  gtk_clist_set_compare_func(GTK_CLIST(gl_config->mapl), map_sort);
-  clist_set_tooltips(GTK_CLIST(gl_config->mapl), gl_config->tooltips,
-		     "Trier par nom", "Trier par description", 
-		     "Trier par nombre de joueurs",
-		     "Trier par auteur", "Trier par taille", NULL);
-  gl_config->mapa = 
-    mysql_adder_make("Maps", "Ajout d'une carte", map_refresh, 6,
-		     "Nom: ", "nom", "Nom de la carte", sql_add_str, 80,
-		     "Description: ", "descr", "Description de la carte",
-		     sql_add_str, 120,
-		     "Nombre de joueurs: ", "joueurs", 
-		     "Nombre de joueurs maximum", sql_add_num, 1, 42, 4,
-		     "Taille: ", "taille", 
-		     "Taille de la carte (ex: 100x100)", sql_add_str, 40,
-		     "Publique: ", "public", 
-		     "Cette carte est-elle visible par les autres?",
-		     sql_add_flag, TRUE,
-		     "Fichier: ", "fichier", "Nom du fichier carte",
-		     sql_add_file, "./maps");
-
-  gl_config->prgl = create_clist(5, 0, 
-				 "Nom", "Auteur", "Meilleur score", 
-				 "Score moyen", "Tournois", 
-				 80, 120, 80, 70, 30, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_DESCENDING, 
-				 GTK_SORT_DESCENDING, 
-				 GTK_SORT_DESCENDING);
-  create_page(widget, gl_config->prgl, "Champions", 4,
-	      " Actualiser ", "Réactualiser la liste", prg_refresh, 
-	      " Ajouter ", "Ajouter un champion", prg_add, 
-	      " Modifier ", "Modifier un champion", prg_edit,
-	      " Supprimer ", "Supprimer les champions sélectionnés", 
-	      prg_remove);
-  clist_set_tooltips(GTK_CLIST(gl_config->prgl), gl_config->tooltips,
-		     "Trier par nom", "Trier par auteur", 
-		     "Trier par meilleur score",  "Trier par sore moyen", 
-		     "", NULL);
-  gtk_clist_set_selection_mode(GTK_CLIST(gl_config->prgl), 
-			       GTK_SELECTION_EXTENDED);
-  gtk_clist_set_compare_func(GTK_CLIST(gl_config->prgl), prg_sort);
-  gl_config->prga = 
-    mysql_adder_make("Champions", "Ajout d'un chamion", prg_refresh, 4,
-		     "Nom: ", "nom", "Nom du champion", sql_add_str, 80,
-		     "Publique: ", "public", 
-		     "Les autres candidats peuvent-ils tester "
-		     "leur champion contre le tien?", sql_add_flag, TRUE,
-		     "Tournois: ", "tourn", 
-		     "Inclure dans les tournois ? ", sql_add_flag, FALSE,
-		     "Fichier: ", "fichier", 
-		     "Fichier .so contenant le champion.", sql_add_file, 
-		     "./code");
-  
-  gl_config->matl = create_clist(4, 0, 
-				 "Machine", "Bitmap", "Map", "Joueurs", 
-				 70, 120, 80, 80,
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING, 
-				 GTK_SORT_ASCENDING);
-  create_page(widget, gl_config->matl, "Matchs en cours", 2,
-	      " Actualiser ", "Réactualiser la liste", mat_refresh, 
-	      " Se connecter ", 
-	      "Lancer un client graphique sur les matchs sélectionnés", 
-	      mat_connect); 
-  clist_set_tooltips(GTK_CLIST(gl_config->prgl), gl_config->tooltips,
-		     "Trier par machine", 
-		     "Trier par bitmap (ayant lancé la partie)", 
-		     "Trier par carte",  "Trier par nombre de joueurs", 
-		     NULL);
-  gtk_clist_set_compare_func(GTK_CLIST(gl_config->matl), mat_sort);
-  gtk_clist_set_selection_mode(GTK_CLIST(gl_config->matl), 
-			       GTK_SELECTION_EXTENDED);
-
-  return widget;
+    GtkWidget *widget;
+
+    widget = gtk_notebook_new();
+    gl_config->notebook = GTK_NOTEBOOK(widget);
+    gtk_notebook_popup_enable(gl_config->notebook);
+    gtk_notebook_set_homogeneous_tabs(gl_config->notebook, TRUE);
+    gtk_widget_show(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "switch-page", switch_page, NULL);
+    gl_config->bmpl = create_clist(7, 0,
+                                   "Login", "Nom", "Pr�nom", "Pseudo",
+                                   "Machine", "Statut", "Type",
+                                   50, 110, 110, 90, 60, 60, 60,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING);
+    gtk_clist_set_compare_func(GTK_CLIST(gl_config->bmpl), bmp_sort);
+    clist_set_tooltips(GTK_CLIST(gl_config->bmpl), gl_config->tooltips,
+                       "Trier par login", "Trier par nom", "Trier par pr�nom",
+                       "Trier par pseudo", "Trier par machine",
+                       "Trier par satut", "S�parer les orgas des bitmaps", NULL);
+
+    create_page(widget, gl_config->bmpl, "Personnes", 2,
+                " Actualiser ", "R�actualiser la liste", bmp_refresh,
+                " Ecrire ", "Envoyer un message", bmp_send_message);
+    gtk_clist_set_selection_mode(GTK_CLIST(gl_config->bmpl),
+                                 GTK_SELECTION_EXTENDED);
+
+    gl_config->mapl = create_clist(5, 0,
+                                   "Nom", "Description", "Joueurs",
+                                   "Auteur", "Taille",
+                                   80, 150, 50, 50, 50,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING);
+    create_page(widget, gl_config->mapl, "Cartes", 4,
+                " Actualiser ", "R�actualiser la liste", map_refresh,
+                " Ajouter ", "Ajouter une carte perso", map_add,
+                " Modifier ", "Modifier une carte", map_edit,
+                " Supprimer ", "Supprimer la carte s�lectionn�e", map_remove);
+    gtk_clist_set_compare_func(GTK_CLIST(gl_config->mapl), map_sort);
+    clist_set_tooltips(GTK_CLIST(gl_config->mapl), gl_config->tooltips,
+                       "Trier par nom", "Trier par description",
+                       "Trier par nombre de joueurs",
+                       "Trier par auteur", "Trier par taille", NULL);
+    gl_config->mapa =
+            mysql_adder_make("Maps", "Ajout d'une carte", map_refresh, 6,
+                             "Nom: ", "nom", "Nom de la carte", sql_add_str, 80,
+                             "Description: ", "descr", "Description de la carte",
+                             sql_add_str, 120,
+                             "Nombre de joueurs: ", "joueurs",
+                             "Nombre de joueurs maximum", sql_add_num, 1, 42, 4,
+                             "Taille: ", "taille",
+                             "Taille de la carte (ex: 100x100)", sql_add_str, 40,
+                             "Publique: ", "public",
+                             "Cette carte est-elle visible par les autres?",
+                             sql_add_flag, TRUE,
+                             "Fichier: ", "fichier", "Nom du fichier carte",
+                             sql_add_file, "./maps");
+
+    gl_config->prgl = create_clist(5, 0,
+                                   "Nom", "Auteur", "Meilleur score",
+                                   "Score moyen", "Tournois",
+                                   80, 120, 80, 70, 30,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_DESCENDING,
+                                   GTK_SORT_DESCENDING,
+                                   GTK_SORT_DESCENDING);
+    create_page(widget, gl_config->prgl, "Champions", 4,
+                " Actualiser ", "R�actualiser la liste", prg_refresh,
+                " Ajouter ", "Ajouter un champion", prg_add,
+                " Modifier ", "Modifier un champion", prg_edit,
+                " Supprimer ", "Supprimer les champions s�lectionn�s",
+                prg_remove);
+    clist_set_tooltips(GTK_CLIST(gl_config->prgl), gl_config->tooltips,
+                       "Trier par nom", "Trier par auteur",
+                       "Trier par meilleur score", "Trier par sore moyen",
+                       "", NULL);
+    gtk_clist_set_selection_mode(GTK_CLIST(gl_config->prgl),
+                                 GTK_SELECTION_EXTENDED);
+    gtk_clist_set_compare_func(GTK_CLIST(gl_config->prgl), prg_sort);
+    gl_config->prga =
+            mysql_adder_make("Champions", "Ajout d'un chamion", prg_refresh, 4,
+                             "Nom: ", "nom", "Nom du champion", sql_add_str, 80,
+                             "Publique: ", "public",
+                             "Les autres candidats peuvent-ils tester "
+                             "leur champion contre le tien?", sql_add_flag, TRUE,
+                             "Tournois: ", "tourn",
+                             "Inclure dans les tournois ? ", sql_add_flag, FALSE,
+                             "Fichier: ", "fichier",
+                             "Fichier .so contenant le champion.", sql_add_file,
+                             "./code");
+
+    gl_config->matl = create_clist(4, 0,
+                                   "Machine", "Bitmap", "Map", "Joueurs",
+                                   70, 120, 80, 80,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING,
+                                   GTK_SORT_ASCENDING);
+    create_page(widget, gl_config->matl, "Matchs en cours", 2,
+                " Actualiser ", "R�actualiser la liste", mat_refresh,
+                " Se connecter ",
+                "Lancer un client graphique sur les matchs s�lectionn�s",
+                mat_connect);
+    clist_set_tooltips(GTK_CLIST(gl_config->prgl), gl_config->tooltips,
+                       "Trier par machine",
+                       "Trier par bitmap (ayant lanc� la partie)",
+                       "Trier par carte", "Trier par nombre de joueurs",
+                       NULL);
+    gtk_clist_set_compare_func(GTK_CLIST(gl_config->matl), mat_sort);
+    gtk_clist_set_selection_mode(GTK_CLIST(gl_config->matl),
+                                 GTK_SELECTION_EXTENDED);
+
+    return widget;
 }
 
 void create_gtk_stuff()
 {
-  GtkWidget *vbox;
-
-  gl_config->tooltips = gtk_tooltips_new();
-  gl_config->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-  gtk_signal_connect(GTK_OBJECT(gl_config->window), "delete-event", 
-		     GTK_SIGNAL_FUNC(byebye), NULL);
-  gtk_window_set_title(GTK_WINDOW(gl_config->window), 
-		       "Meta-client Prologin 2001");
-  gtk_window_set_default_size(GTK_WINDOW(gl_config->window), 650, 250);
-  gtk_widget_show(gl_config->window);
-
-  vbox = gtk_vbox_new(FALSE, 4);
-  gtk_container_add(GTK_CONTAINER(gl_config->window), vbox);
-
-  gtk_box_pack_start(GTK_BOX(vbox), create_menubar(), FALSE, FALSE, 0);
-  gtk_box_pack_start(GTK_BOX(vbox), create_main_area(), TRUE, TRUE, 0);
-  
-  prg_refresh(NULL, NULL);
-  bmp_refresh(NULL, NULL);
-  map_refresh(NULL, NULL);
-  mat_refresh(NULL, NULL);
-
-  gtk_widget_show(vbox);  
+    GtkWidget *vbox;
+
+    gl_config->tooltips = gtk_tooltips_new();
+    gl_config->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_signal_connect(GTK_OBJECT(gl_config->window), "delete-event",
+                       GTK_SIGNAL_FUNC(byebye), NULL);
+    gtk_window_set_title(GTK_WINDOW(gl_config->window),
+                         "Meta-client Prologin 2001");
+    gtk_window_set_default_size(GTK_WINDOW(gl_config->window), 650, 250);
+    gtk_widget_show(gl_config->window);
+
+    vbox = gtk_vbox_new(FALSE, 4);
+    gtk_container_add(GTK_CONTAINER(gl_config->window), vbox);
+
+    gtk_box_pack_start(GTK_BOX(vbox), create_menubar(), FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), create_main_area(), TRUE, TRUE, 0);
+
+    prg_refresh(NULL, NULL);
+    bmp_refresh(NULL, NULL);
+    map_refresh(NULL, NULL);
+    mat_refresh(NULL, NULL);
+
+    gtk_widget_show(vbox);
 }

+ 29 - 14
meta-client/include/mclient.h

@@ -1,5 +1,3 @@
-/* $Id: mclient.h,v 1.19 2001/05/03 23:17:47 kilobug Exp $ */
-
 #ifndef __PROLO_MCLIENT_H__
 #define __PROLO_MCLIENT_H__
 
@@ -19,47 +17,64 @@ extern conf_t *gl_config;
 
 struct _conf_t
 {
-  MYSQL *mysql;
-  GtkWidget *bmpl, *mapl, *prgl, *result, *matl;  /* CList */
-  sql_add_t *mapa, *prga;
-  GtkWidget *window;
-  GtkWidget *menunb[NOTEBOOK_PAGE_NUM];
-  GtkNotebook *notebook;
-  GtkTooltips *tooltips;
-  char *hostname;
-  const char *bindir;
-  const char *gfx_client, *server;
-  const char *db, *host;
-  gboolean staff;
+    MYSQL *mysql;
+    GtkWidget *bmpl, *mapl, *prgl, *result, *matl;  /* CList */
+    sql_add_t *mapa, *prga;
+    GtkWidget *window;
+    GtkWidget *menunb[NOTEBOOK_PAGE_NUM];
+    GtkNotebook *notebook;
+    GtkTooltips *tooltips;
+    char *hostname;
+    const char *bindir;
+    const char *gfx_client, *server;
+    const char *db, *host;
+    bool staff;
 };
 
 void init(int argc, char **argv);
+
 void set_my_status(int stat);
+
 void byebye(GtkWidget *widget, void *data);
 
 void create_gtk_stuff();
+
 GtkWidget *create_menubar();
 
 int bmp_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2);
+
 void bmp_refresh(GtkWidget *wid, void *data);
+
 void bmp_send_message(GtkWidget *wid, void *data);
 
 int map_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2);
+
 void map_refresh(GtkWidget *wid, void *data);
+
 void map_add(GtkWidget *wid, void *data);
+
 void map_remove(GtkWidget *wid, void *data);
 
 int prg_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2);
+
 void prg_refresh(GtkWidget *wid, void *data);
+
 void prg_add(GtkWidget *wid, void *data);
+
 void prg_remove(GtkWidget *wid, void *data);
+
 void prg_edit(GtkWidget *wid, void *data);
 
 int mat_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2);
+
 void mat_refresh(GtkWidget *wid, void *data);
+
 void mat_connect(GtkWidget *wid, void *data);
+
 GtkWidget *start_match_box();
+
 GtkWidget *start_tournois_box();
+
 void map_edit(GtkWidget *wid, void *data);
 
 #endif

+ 38 - 30
meta-client/include/mysql.h

@@ -1,5 +1,3 @@
-/* $Id: mysql.h,v 1.11 2001/05/03 23:17:47 kilobug Exp $ */
-
 #ifndef __PROLO_MCLIENT_MYSQL_H__
 #define __PROLO_MCLIENT_MYSQL_H__
 
@@ -8,62 +6,71 @@
 #include <mysql/mysql.h>
 
 int mysql_query_gtk(MYSQL *mysql, const char *query);
+
 int mysql_get_int(MYSQL *mysql, const char *query, ...);
+
 char *mysql_get_str(MYSQL *mysql, const char *query, ...);
+
 void mysql_do_query(MYSQL *mysql, const char *query, ...);
 
 typedef struct _sql_list_t sql_list_t;
 
 typedef char *ml_cvt_func_t(const char *val, void *data);
+
 typedef GdkColor *ml_color_func_t(const sql_list_t *list, int id, void *data);
 
 typedef struct _sql_item_t
 {
-  ml_cvt_func_t *cvt_func;
-  GtkDestroyNotify destroy_func;
-  void *data;
+    ml_cvt_func_t *cvt_func;
+    GtkDestroyNotify destroy_func;
+    void *data;
 } sql_item_t;
 
 struct _sql_list_t
 {
-  const char *query;
-  int nb_fields;
-  sql_item_t *items;
-  GtkCList *clist;
-  ml_color_func_t *color_func;
-  void *color_func_data;
+    const char *query;
+    int nb_fields;
+    sql_item_t *items;
+    GtkCList *clist;
+    ml_color_func_t *color_func;
+    void *color_func_data;
 };
 
 typedef struct _sql_add_item_t
 {
-  const char *field;
-  enum { sql_add_str, sql_add_num, sql_add_flag, sql_add_file } type;
-  void *param;
-  GtkWidget *widget;
-  const char *tooltip, *label;
+    const char *field;
+    enum
+    {
+        sql_add_str, sql_add_num, sql_add_flag, sql_add_file
+    } type;
+    void *param;
+    GtkWidget *widget;
+    const char *tooltip, *label;
 } sql_add_item_t;
 
 typedef struct _sql_add_t
 {
-  const char *table;
-  GSList *items;
-  GtkWidget *widget;
-  GtkSignalFunc callback;
-  int id;
+    const char *table;
+    GSList *items;
+    GtkWidget *widget;
+    GtkSignalFunc callback;
+    int id;
 } sql_add_t;
 
-void mysql_list_set_color_func(sql_list_t *list, ml_color_func_t *callback, 
-			       void *data);
+void mysql_list_set_color_func(sql_list_t *list, ml_color_func_t *callback,
+                               void *data);
+
 void mysql_list_refresh(const sql_list_t *l, const char *where);
-void mysql_list_remove(const char *table, GtkCList *clist, 
-		       GtkSignalFunc refresh_callback);
+
+void mysql_list_remove(const char *table, GtkCList *clist,
+                       GtkSignalFunc refresh_callback);
 
 /* Syntax: make_mysql_list(query, nb_fields, clist,
                            num1, convert_callback1, destroy_callback1, data1,
                            num2, convert_callback2, destroy_callback2, data2,
 			   ..., -1); */
 sql_list_t *mysql_list_make(const char *query, int nb_fields, GtkCList *clist,
-			    ...);
+                            ...);
 
 /* Syntax: make_mysql_adder(table, window_title, callback, nb_fields,
                             label1, field_name1, tooltip, type1, { args1 },
@@ -77,9 +84,10 @@ sql_list_t *mysql_list_make(const char *query, int nb_fields, GtkCList *clist,
 */
 
 sql_add_t *mysql_adder_make(const char *table, const char *title,
-			    GtkSignalFunc callback, int nb, ...);
+                            GtkSignalFunc callback, int nb, ...);
+
+void mysql_list_edit(const char *title, const GtkCList *sel,
+                     const sql_add_t *adder,
+                     GtkSignalFunc refresh_callback);
 
-void mysql_list_edit(const char *title, const GtkCList *sel, 
-		     const sql_add_t *adder, 
-		     GtkSignalFunc refresh_callback);
 #endif

+ 19 - 17
meta-client/include/tournois.h

@@ -1,23 +1,25 @@
-/* $Id: tournois.h,v 1.4 2001/05/07 02:41:36 kilobug Exp $ */
-
 typedef struct _rt_t
 {
-  int mapid;
-  int nbp, nbt, nbm, nbc;
-  char *cmd;
-  enum { met_comb = 0, met_rand = 1, met_pyr = 3, met_rot = 2 } methode;
-  int *champ, *chmp; 
-  GtkWidget *dialog, *textarea;
-  int cur;
-  void *data;
-  int gdki, fd;
-  char *buf;
-  char *map;
-  gboolean run, disp;
-  float *scores;
-  int mysql_id;
-  gboolean timeout;
+    int mapid;
+    int nbp, nbt, nbm, nbc;
+    char *cmd;
+    enum
+    {
+        met_comb = 0, met_rand = 1, met_pyr = 3, met_rot = 2
+    } methode;
+    int *champ, *chmp;
+    GtkWidget *dialog, *textarea;
+    int cur;
+    void *data;
+    int gdki, fd;
+    char *buf;
+    char *map;
+    bool run, disp;
+    float *scores;
+    int mysql_id;
+    bool timeout;
 } rt_t;
 
 void trn_init(rt_t *rt);
+
 void trn_free(rt_t *rt);

+ 100 - 87
meta-client/init.c

@@ -1,5 +1,3 @@
-/* $Id: init.c,v 1.26 2001/05/04 14:36:09 kilobug Exp $ */
-
 #include "mclient.h"
 #include <sys/wait.h>
 #include <time.h>
@@ -20,124 +18,139 @@
 
 void byebye(GtkWidget *widget, void *data)
 {
-  gtk_main_quit();
+    gtk_main_quit();
 }
 
 static void sigchild()
 {
-  wait(NULL);
+    wait(NULL);
 }
 
 static void clean_abort()
 {
-  exit(2);
+    exit(2);
 }
 
 static void clean_quit()
 {
-  set_my_status(STATUT_ABSENT);
+    set_my_status(STATUT_ABSENT);
 }
 
 void set_my_status(int stat)
 {
-  char buf[MYSQL_BUFFER_SIZE];
+    char buf[MYSQL_BUFFER_SIZE];
 
-  g_snprintf(buf, MYSQL_BUFFER_SIZE, 
-	     "UPDATE Bitmaps SET statut=%d, machine='%s' WHERE id=%d",
-	     stat, gl_config->hostname, getuid());
-  mysql_query(gl_config->mysql, buf);
+    g_snprintf(buf, MYSQL_BUFFER_SIZE,
+               "UPDATE Bitmaps SET statut=%d, machine='%s' WHERE id=%d",
+               stat, gl_config->hostname, getuid());
+    mysql_query(gl_config->mysql, buf);
 }
 
 static void get_args(int argc, char **argv, conf_t *res)
 {
-  int i;
+    int i;
 
-  res->db = MYSQL_DB;
-  res->host = NULL;
+    res->db = MYSQL_DB;
+    res->host = NULL;
 
-  for (i = 1; i < argc - 1; i++)
+    for ( i = 1 ; i < argc - 1 ; i++ )
     {
-      if (!strcmp(argv[i], "-r"))
-	res->host = argv[++i];
-      else
-	if (!strcmp(argv[i], "-d"))
-	  res->db = argv[++i];
-      else
-	fprintf(stderr, "Paramètre inconnu: %s\n", argv[i]);
+        if ( !strcmp(argv[i], "-r"))
+        {
+            res->host = argv[++i];
+        }
+        else if ( !strcmp(argv[i], "-d"))
+        {
+            res->db = argv[++i];
+        }
+        else
+        {
+            fprintf(stderr, "Param�tre inconnu: %s\n", argv[i]);
+        }
     }
 }
 
 void init(int argc, char **argv)
 {
-  conf_t *res;
-  char *passwd, c;
-  int i;  
-
-  srandom(time(NULL));
-  res = g_malloc(sizeof(*res));
-  res->hostname = g_malloc(MYSQL_BUFFER_SIZE);
-  gethostname(res->hostname, MYSQL_BUFFER_SIZE);
-
-  res->bindir = g_dirname(argv[0]);
-  if (g_path_is_absolute(SERVER) || (res->bindir[0] != argv[0][0]))
-    res->server = SERVER;
-  else
-    res->server = g_strconcat(res->bindir, G_DIR_SEPARATOR_S, SERVER, 
-				  NULL);
-  if (g_path_is_absolute(GFX_CLIENT) || (res->bindir[0] != argv[0][0]))
-    res->gfx_client = GFX_CLIENT;
-  else
-    res->gfx_client = g_strconcat(res->bindir, G_DIR_SEPARATOR_S, GFX_CLIENT,
-				  NULL);
-
-  get_args(argc, argv, res);
-
-  res->mysql = NULL;
-  res->matl = res->bmpl = res->mapl = res->prgl = res->result = NULL;
-  res->mapa = res->prga = NULL;
-  res->window = NULL;
-  for (i = 0; i < NOTEBOOK_PAGE_NUM; i++)
-    res->menunb[i] = NULL;
-
-  res->mysql = mysql_init(NULL);
-  mysql_options(res->mysql, MYSQL_READ_DEFAULT_GROUP, "meta-client");
-  passwd = g_strdup(MYSQL_PASSWORD);
-  for (i = 0; i < strlen(passwd); i += 2)
+    conf_t *res;
+    char *passwd, c;
+    int i;
+
+    srandom(time(NULL));
+    res = g_malloc(sizeof(*res));
+    res->hostname = g_malloc(MYSQL_BUFFER_SIZE);
+    gethostname(res->hostname, MYSQL_BUFFER_SIZE);
+
+    res->bindir = g_dirname(argv[0]);
+    if ( g_path_is_absolute(SERVER) || ( res->bindir[0] != argv[0][0] ))
+    {
+        res->server = SERVER;
+    }
+    else
+    {
+        res->server = g_strconcat(res->bindir, G_DIR_SEPARATOR_S, SERVER,
+                                  NULL);
+    }
+    if ( g_path_is_absolute(GFX_CLIENT) || ( res->bindir[0] != argv[0][0] ))
+    {
+        res->gfx_client = GFX_CLIENT;
+    }
+    else
+    {
+        res->gfx_client = g_strconcat(res->bindir, G_DIR_SEPARATOR_S, GFX_CLIENT,
+                                      NULL);
+    }
+
+    get_args(argc, argv, res);
+
+    res->mysql = NULL;
+    res->matl = res->bmpl = res->mapl = res->prgl = res->result = NULL;
+    res->mapa = res->prga = NULL;
+    res->window = NULL;
+    for ( i = 0 ; i < NOTEBOOK_PAGE_NUM ; i++ )
+    {
+        res->menunb[i] = NULL;
+    }
+
+    res->mysql = mysql_init(NULL);
+    mysql_options(res->mysql, MYSQL_READ_DEFAULT_GROUP, "meta-client");
+    passwd = g_strdup(MYSQL_PASSWORD);
+    for ( i = 0 ; i < strlen(passwd) ; i += 2 )
     {
-      c = passwd[i];
-      passwd[i] = passwd[i + 1];
-      passwd[i + 1] = c;
+        c = passwd[i];
+        passwd[i] = passwd[i + 1];
+        passwd[i + 1] = c;
     }
-  if (mysql_real_connect(res->mysql, MYSQL_HOST, MYSQL_LOGIN, passwd,
-			 res->db, MYSQL_PORT, NULL, 0) == NULL)
+    if ( mysql_real_connect(res->mysql, MYSQL_HOST, MYSQL_LOGIN, passwd,
+                            res->db, MYSQL_PORT, NULL, 0) == NULL)
     {
-      fprintf(stderr, "Failed to connect to database: Error: %s\n",
-	      mysql_error(res->mysql));
-      exit(1);
+        fprintf(stderr, "Failed to connect to database: Error: %s\n",
+                mysql_error(res->mysql));
+        exit(1);
     }
-  gl_config = res;
-  set_my_status(STATUT_PRESENT);
-  i = mysql_get_int(gl_config->mysql,
-		    "SELECT id FROM Bitmaps WHERE id = %d", 
-		    getuid());
-  if (i != getuid())
+    gl_config = res;
+    set_my_status(STATUT_PRESENT);
+    i = mysql_get_int(gl_config->mysql,
+                      "SELECT id FROM Bitmaps WHERE id = %d",
+                      getuid());
+    if ( i != getuid())
     {
-      fprintf(stderr, "You're nobody. Go away.\n");
-      exit(1);
+        fprintf(stderr, "You're nobody. Go away.\n");
+        exit(1);
     }
-  res->staff = mysql_get_int(gl_config->mysql,
-			     "SELECT staff FROM Bitmaps WHERE id = %d", 
-			     getuid());
-
-  atexit(clean_quit);
-  signal(SIGINT, clean_abort);
-  signal(SIGHUP, clean_abort);
-  signal(SIGQUIT, clean_abort);
-  signal(SIGABRT, clean_abort);
-  signal(SIGTERM, clean_abort);
-  signal(SIGCHLD, sigchild);
-  setlocale(LC_ALL, "fr_FR");
-  gtk_set_locale();  
-  setlocale(LC_NUMERIC, "C");
-  gtk_init(&argc, &argv);
+    res->staff = mysql_get_int(gl_config->mysql,
+                               "SELECT staff FROM Bitmaps WHERE id = %d",
+                               getuid());
+
+    atexit(clean_quit);
+    signal(SIGINT, clean_abort);
+    signal(SIGHUP, clean_abort);
+    signal(SIGQUIT, clean_abort);
+    signal(SIGABRT, clean_abort);
+    signal(SIGTERM, clean_abort);
+    signal(SIGCHLD, sigchild);
+    setlocale(LC_ALL, "fr_FR");
+    gtk_set_locale();
+    setlocale(LC_NUMERIC, "C");
+    gtk_init(&argc, &argv);
 }

+ 4 - 6
meta-client/main.c

@@ -1,13 +1,11 @@
-/* $Id: main.c,v 1.2 2001/04/11 14:42:23 kilobug Exp $ */
-
 #include "mclient.h"
 
 conf_t *gl_config = NULL;
 
 int main(int argc, char **argv)
 {
-  init(argc, argv);
-  create_gtk_stuff();
-  gtk_main();
-  return 0;
+    init(argc, argv);
+    create_gtk_stuff();
+    gtk_main();
+    return 0;
 }

+ 63 - 56
meta-client/maps.c

@@ -1,96 +1,103 @@
-/* $Id: maps.c,v 1.10 2001/04/20 09:47:49 kilobug Exp $ */
-
 #include "mclient.h"
 
 int map_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
-  int i = 0;
-  
-  switch (clist->sort_column)
+    int i = 0;
+
+    switch ( clist->sort_column )
     {
-    case 0: case 1: case 3:
-      return clist_compare_str(clist, ptr1, ptr2);
+    case 0:
+    case 1:
+    case 3:
+        return clist_compare_str(clist, ptr1, ptr2);
     case 2:
-      return clist_compare_float(clist, ptr1, ptr2);
+        return clist_compare_float(clist, ptr1, ptr2);
     case 4:
-      i = clist_compare_float(clist, ptr1, ptr2);
-      if (i == 0)
-	i = clist_compare_str(clist, ptr1, ptr2);
-      return i;
+        i = clist_compare_float(clist, ptr1, ptr2);
+        if ( i == 0 )
+        {
+            i = clist_compare_str(clist, ptr1, ptr2);
+        }
+        return i;
     }
-  return 0;
+    return 0;
 }
 
 static char *map_owner(const char *val, void *data)
 {
-  int i;
+    int i;
 
-  i = atoi(val);
-  if (i < 0)
-    return g_strdup("Prologin");
-  else
-    return mysql_get_str(gl_config->mysql, 
-			 "SELECT pseudo FROM Bitmaps WHERE id=%d", i);
+    i = atoi(val);
+    if ( i < 0 )
+    {
+        return g_strdup("Prologin");
+    }
+    else
+    {
+        return mysql_get_str(gl_config->mysql,
+                             "SELECT pseudo FROM Bitmaps WHERE id=%d", i);
+    }
 }
 
 static GdkColor *map_color(const sql_list_t *l, int id, void *data)
 {
-  GdkColor *col = NULL;
-  int auteur;
+    GdkColor *col = NULL;
+    int auteur;
 
-  auteur = mysql_get_int(gl_config->mysql, 
-			 "SELECT auteur FROM Maps WHERE id=%d", id);
-  if ((auteur == -1) || (mysql_get_int(gl_config->mysql, 
-				       "SELECT staff FROM Bitmaps "
-				       "WHERE id=%d", auteur)))
+    auteur = mysql_get_int(gl_config->mysql,
+                           "SELECT auteur FROM Maps WHERE id=%d", id);
+    if (( auteur == -1 ) || ( mysql_get_int(gl_config->mysql,
+                                            "SELECT staff FROM Bitmaps "
+                                            "WHERE id=%d", auteur)))
+    {
+        col = g_malloc(sizeof(*col));
+        gdk_color_parse("blue", col);
+    }
+    else if ( auteur == getuid())
+    {
+        col = g_malloc(sizeof(*col));
+        gdk_color_parse("#009000", col);
+    }
+    if ( col != NULL )
     {
-      col = g_malloc(sizeof(*col));
-      gdk_color_parse("blue", col);
+        gdk_color_alloc(gdk_colormap_get_system(), col);
     }
-  else
-    if (auteur == getuid())
-      {
-	col = g_malloc(sizeof(*col));
-	gdk_color_parse("#009000", col);
-      }
-  if (col != NULL)
-    gdk_color_alloc(gdk_colormap_get_system(), col);
-  return col;
+    return col;
 }
 
 void map_refresh(GtkWidget *wid, void *data)
 {
-  static sql_list_t *lst = NULL;
-  char *buf;
+    static sql_list_t *lst = NULL;
+    char *buf;
 
-  if (lst == NULL)
+    if ( lst == NULL )
     {
-      buf = g_malloc(MYSQL_BUFFER_SIZE);
-      g_snprintf(buf, MYSQL_BUFFER_SIZE,
-		 "SELECT id, nom, descr, joueurs, auteur, taille "
-		 "FROM   Maps "
-		 "WHERE  (actif) "
-		 "  AND  ((public) OR (auteur = %d) OR (%d = 1))",
-		 getuid(), gl_config->staff);
-      lst = mysql_list_make(buf, 6, GTK_CLIST(gl_config->mapl),
-			    4, map_owner, g_free, NULL, -1);      
-      mysql_list_set_color_func(lst, map_color, NULL);
+        buf = g_malloc(MYSQL_BUFFER_SIZE);
+        g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                   "SELECT id, nom, descr, joueurs, auteur, taille "
+                   "FROM   Maps "
+                   "WHERE  (actif) "
+                   "  AND  ((public) OR (auteur = %d) OR (%d = 1))",
+                   getuid(), gl_config->staff);
+        lst = mysql_list_make(buf, 6, GTK_CLIST(gl_config->mapl),
+                              4, map_owner, g_free, NULL, -1);
+        mysql_list_set_color_func(lst, map_color, NULL);
     }
-  mysql_list_refresh(lst, NULL);
+    mysql_list_refresh(lst, NULL);
 }
 
 void map_add(GtkWidget *wid, void *data)
 {
-  gtk_widget_show(gl_config->mapa->widget);
+    gtk_widget_show(gl_config->mapa->widget);
 }
 
 void map_remove(GtkWidget *wid, void *data)
 {
-  mysql_list_remove("Maps", GTK_CLIST(gl_config->mapl), map_refresh);
+    mysql_list_remove("Maps", GTK_CLIST(gl_config->mapl), map_refresh);
 }
 
 void map_edit(GtkWidget *wid, void *data)
 {
-  mysql_list_edit("Modification d'une carte", GTK_CLIST(gl_config->mapl), 
-		  gl_config->mapa, map_refresh);
+    mysql_list_edit("Modification d'une carte", GTK_CLIST(gl_config->mapl),
+                    gl_config->mapa, map_refresh);
 }

+ 42 - 42
meta-client/matchs.c

@@ -1,65 +1,65 @@
-/* $Id: matchs.c,v 1.13 2001/05/01 13:34:20 kilobug Exp $ */
-
 #include "mclient.h"
 
 int mat_sort(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
-  switch (clist->sort_column)
+    switch ( clist->sort_column )
     {
-    case 0: case 1: case 2:
-      return clist_compare_str(clist, ptr1, ptr2);
+    case 0:
+    case 1:
+    case 2:
+        return clist_compare_str(clist, ptr1, ptr2);
     case 3:
-      return clist_compare_float(clist, ptr1, ptr2);
+        return clist_compare_float(clist, ptr1, ptr2);
     }
-  return 0;
+    return 0;
 }
 
 void mat_refresh(GtkWidget *wid, void *data)
 {
-  static sql_list_t *lst = NULL;
-  char *buf;
+    static sql_list_t *lst = NULL;
+    char *buf;
 
-  if (lst == NULL)
+    if ( lst == NULL )
     {
-      buf = g_malloc(MYSQL_BUFFER_SIZE);
-      g_snprintf(buf, MYSQL_BUFFER_SIZE,
-		 "SELECT m.id, CONCAT(m.host, ':', m.port), b.pseudo, map.nom,"
-                 "       m.joueurs "
-		 "FROM   Maps map, Matchs m, Bitmaps b "
-		 "WHERE  (b.id = m.auteur) AND (map.id = m.map) "
-		 "  AND  (m.statut = 1) "
-                 "  AND  ((m.public) OR (m.auteur = %d) OR (%d = 1))",
-		 getuid(), gl_config->staff);
-      lst = mysql_list_make(buf, 5, GTK_CLIST(gl_config->matl), -1);
+        buf = g_malloc(MYSQL_BUFFER_SIZE);
+        g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                   "SELECT m.id, CONCAT(m.host, ':', m.port), b.pseudo, map.nom,"
+                   "       m.joueurs "
+                   "FROM   Maps map, Matchs m, Bitmaps b "
+                   "WHERE  (b.id = m.auteur) AND (map.id = m.map) "
+                   "  AND  (m.statut = 1) "
+                   "  AND  ((m.public) OR (m.auteur = %d) OR (%d = 1))",
+                   getuid(), gl_config->staff);
+        lst = mysql_list_make(buf, 5, GTK_CLIST(gl_config->matl), -1);
     }
-  mysql_list_refresh(lst, NULL);
+    mysql_list_refresh(lst, NULL);
 }
 
 void mat_connect(GtkWidget *wid, void *data)
 {
-  GList *l;
-  char *s;
-  char buf[12];
-  int i, id;
+    GList *l;
+    char *s;
+    char buf[12];
+    int i, id;
 
-  for (l = GTK_CLIST(gl_config->matl)->selection; l != NULL; l = l->next)
+    for ( l = GTK_CLIST(gl_config->matl)->selection ; l != NULL ; l = l->next )
     {
-      id = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->matl), 
-					    GPOINTER_TO_INT(l->data)));
-      i = mysql_get_int(gl_config->mysql, 
-			"SELECT port FROM Matchs WHERE id = %d", 
-			id);
-      s = mysql_get_str(gl_config->mysql, 
-			"SELECT host FROM Matchs WHERE id = %d", 
-			id);
-      g_snprintf(buf, 12, "%d", i);
-      if (!fork())
-	{	  
-	  execlp(gl_config->gfx_client, gl_config->gfx_client, 
-		 "-h", s, "-p", buf, NULL);
-	  _exit(0);
-	}
-      g_free(s);
+        id = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->matl),
+                                              GPOINTER_TO_INT(l->data)));
+        i = mysql_get_int(gl_config->mysql,
+                          "SELECT port FROM Matchs WHERE id = %d",
+                          id);
+        s = mysql_get_str(gl_config->mysql,
+                          "SELECT host FROM Matchs WHERE id = %d",
+                          id);
+        g_snprintf(buf, 12, "%d", i);
+        if ( !fork())
+        {
+            execlp(gl_config->gfx_client, gl_config->gfx_client,
+                   "-h", s, "-p", buf, NULL);
+            _exit(0);
+        }
+        g_free(s);
     }
 }
 

+ 114 - 107
meta-client/menubar.c

@@ -1,155 +1,162 @@
-/* $Id: menubar.c,v 1.11 2001/05/03 23:17:47 kilobug Exp $ */
-
 #include "mclient.h"
 
 #define ZLOCK_COMMAND "zlock -immed"
 
 static void menu_disp_about(GtkWidget *wi, void *data)
 {
-  GtkWidget *dialog;
-  GtkWidget *widget;
-  GtkAccelGroup *accel_group;
-
-  dialog = gtk_dialog_new();
-  accel_group = gtk_accel_group_new();
-  gtk_window_add_accel_group(GTK_WINDOW(&(GTK_DIALOG(dialog)->window)), 
-			     accel_group);
-  gtk_container_set_border_width(GTK_CONTAINER(&(GTK_DIALOG(dialog)->window)),
-				 7);
-  gtk_window_set_title(GTK_WINDOW(&(GTK_DIALOG(dialog)->window)), 
-				  "Finale Prologin 2001");
-  widget = create_label("Meta-client version "VERSION
-			"\n\nContact: info@prologin.org");
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 9);
-  widget = gtk_button_new_with_label(" OK ");
-  gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
-                              GTK_ACCEL_VISIBLE);
-  gtk_widget_show(widget);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), widget, TRUE, 
-		     TRUE, 0);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(destroy_widget), dialog); 
-  gtk_widget_show(dialog);
+    GtkWidget *dialog;
+    GtkWidget *widget;
+    GtkAccelGroup *accel_group;
+
+    dialog = gtk_dialog_new();
+    accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(&( GTK_DIALOG(dialog)->window )),
+                               accel_group);
+    gtk_container_set_border_width(GTK_CONTAINER(&( GTK_DIALOG(dialog)->window )),
+                                   7);
+    gtk_window_set_title(GTK_WINDOW(&( GTK_DIALOG(dialog)->window )),
+                         "Finale Prologin 2001");
+    widget = create_label("Meta-client version "
+    VERSION
+    "\n\nContact: info@prologin.org");
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 9);
+    widget = gtk_button_new_with_label(" OK ");
+    gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
+                               GTK_ACCEL_VISIBLE);
+    gtk_widget_show(widget);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), widget, TRUE,
+                       TRUE, 0);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(destroy_widget), dialog);
+    gtk_widget_show(dialog);
 }
 
 static void menu_zlock(GtkWidget *wi, void *data)
 {
-  set_my_status(STATUT_ZLOCKE);
-  system(ZLOCK_COMMAND);
-  set_my_status(STATUT_PRESENT);
+    set_my_status(STATUT_ZLOCKE);
+    system(ZLOCK_COMMAND);
+    set_my_status(STATUT_PRESENT);
 }
 
 static void menu_set_pseudo(GtkWidget *wi, GtkWidget *entry)
 {
-  mysql_do_query(gl_config->mysql, 
-		 "UPDATE Bitmaps SET pseudo='%s' WHERE id=%d",
-		 gtk_entry_get_text(GTK_ENTRY(entry)), getuid());
-  bmp_refresh(NULL, NULL);
+    mysql_do_query(gl_config->mysql,
+                   "UPDATE Bitmaps SET pseudo='%s' WHERE id=%d",
+                   gtk_entry_get_text(GTK_ENTRY(entry)), getuid());
+    bmp_refresh(NULL, NULL);
 }
 
 static void menu_pseudo(GtkWidget *wi, void *data)
 {
-  static GtkWidget *dialog = NULL;
-  GtkWidget *widget, *hbox, *entry;
-  char *s;
+    static GtkWidget *dialog = NULL;
+    GtkWidget *widget, *hbox, *entry;
+    char *s;
 
-  if (dialog == NULL)
+    if ( dialog == NULL )
     {
-      hbox = gtk_hbox_new(FALSE, 3);
-      gtk_widget_show(hbox);
-      widget = create_label("Pseudo: ");
-      s = mysql_get_str(gl_config->mysql, 
-			"SELECT pseudo FROM Bitmaps WHERE id=%d", getuid());
-      gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-      entry = create_entry(s, 80);
-      g_free(s);
-      gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 9);
-      dialog = create_dialog("Choix d'un pseudo", hbox,
-			     " Valider ", " Annuler ", 
-			     menu_set_pseudo, entry, hide_widget);
-      gtk_signal_connect(GTK_OBJECT(entry), "activate", menu_set_pseudo, 
-			 entry);
-      gtk_signal_connect_after(GTK_OBJECT(entry), "activate", hide_widget, 
-			 dialog);
+        hbox = gtk_hbox_new(FALSE, 3);
+        gtk_widget_show(hbox);
+        widget = create_label("Pseudo: ");
+        s = mysql_get_str(gl_config->mysql,
+                          "SELECT pseudo FROM Bitmaps WHERE id=%d", getuid());
+        gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+        entry = create_entry(s, 80);
+        g_free(s);
+        gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 9);
+        dialog = create_dialog("Choix d'un pseudo", hbox,
+                               " Valider ", " Annuler ",
+                               menu_set_pseudo, entry, hide_widget);
+        gtk_signal_connect(GTK_OBJECT(entry), "activate", menu_set_pseudo,
+                           entry);
+        gtk_signal_connect_after(GTK_OBJECT(entry), "activate", hide_widget,
+                                 dialog);
     }
-  gtk_widget_show(dialog);
+    gtk_widget_show(dialog);
 }
 
 static void menu_upall(GtkWidget *wi, void *data)
 {
-  bmp_refresh(wi, data);
-  prg_refresh(wi, data);
-  map_refresh(wi, data);  
-  mat_refresh(wi, data);
+    bmp_refresh(wi, data);
+    prg_refresh(wi, data);
+    map_refresh(wi, data);
+    mat_refresh(wi, data);
 }
 
 static void menu_runmatch(GtkWidget *wi, void *data)
 {
-  gtk_widget_show(start_match_box());
+    gtk_widget_show(start_match_box());
 }
 
 static void menu_runtournois(GtkWidget *wi, void *data)
 {
-  gtk_widget_show(start_tournois_box());
+    gtk_widget_show(start_tournois_box());
 }
 
 static void menu_ttip(GtkCheckMenuItem *wi, void *data)
 {
-  if (wi->active)
-    gtk_tooltips_enable(gl_config->tooltips);
-  else
-    gtk_tooltips_disable(gl_config->tooltips);
+    if ( wi->active )
+    {
+        gtk_tooltips_enable(gl_config->tooltips);
+    }
+    else
+    {
+        gtk_tooltips_disable(gl_config->tooltips);
+    }
 }
 
 static void menu_nb(GtkCheckMenuItem *wi, void *data, int page)
 {
-  if (wi->active)
-    gtk_notebook_set_page(gl_config->notebook, page - 1);
+    if ( wi->active )
+    {
+        gtk_notebook_set_page(gl_config->notebook, page - 1);
+    }
 }
 
 static GtkItemFactoryEntry gtk_menu_items[] = {
-      { "/_Système",            NULL,         NULL, 0, "<Branch>" },
-      { "/Système/Choisir un _Pseudo", "<control>P",  menu_pseudo, 0, NULL },
-      { "/Système/_Zlock",     "<control>Z",  menu_zlock, 0, NULL },
-      { "/Système/Tout _Actualiser", "<control>A",  menu_upall, 0, NULL },
-      { "/Système/sep1",        NULL, NULL, 0, "<Separator>" },
-      { "/Système/_Quitter",    "<control>Q", byebye, 0, NULL },
-      { "/_Section",           NULL,         NULL, 0, "<Branch>" },
-      { "/Section/_Personnes",  "F1",        menu_nb, 1, "<RadioItem>" },
-      { "/Section/_Cartes",     "F2",        menu_nb, 2, 
-	"<main>/Section/Personnes" },
-      { "/Section/C_hampions",  "F3",        menu_nb, 3, 
-	"<main>/Section/Personnes" },
-      { "/Section/_Matchs en cours",  "F4",  menu_nb, 4, 
-	"<main>/Section/Personnes" },
-      { "/_Match",           NULL,         NULL, 0, "<Branch>" },
-      { "/Match/_Lancer",    "<control>L", menu_runmatch, 0, NULL },
-      { "/Match/_Tournois",  "<control>T", menu_runtournois, 0, NULL },
-      { "/_Aide",               NULL,         NULL, 0, "<LastBranch>" },
-      { "/_Aide/_Bulles d'aide", "<control>B", menu_ttip, 10, "<ToggleItem>" },
-      { "/_Aide/_A propos",     NULL,         menu_disp_about, 0, NULL },
-    };
+        { "/_Syst�me",                   NULL,         NULL,             0,  "<Branch>" },
+        { "/Syst�me/Choisir un _Pseudo", "<control>P", menu_pseudo,      0,  NULL },
+        { "/Syst�me/_Zlock",             "<control>Z", menu_zlock,       0,  NULL },
+        { "/Syst�me/Tout _Actualiser",   "<control>A", menu_upall,       0,  NULL },
+        { "/Syst�me/sep1",               NULL,         NULL,             0,  "<Separator>" },
+        { "/Syst�me/_Quitter",           "<control>Q", byebye,           0,  NULL },
+        { "/_Section",                   NULL,         NULL,             0,  "<Branch>" },
+        { "/Section/_Personnes",         "F1",         menu_nb,          1,  "<RadioItem>" },
+        { "/Section/_Cartes",            "F2",         menu_nb,          2,
+                                                                             "<main>/Section/Personnes" },
+        { "/Section/C_hampions",         "F3",         menu_nb,          3,
+                                                                             "<main>/Section/Personnes" },
+        { "/Section/_Matchs en cours",   "F4",         menu_nb,          4,
+                                                                             "<main>/Section/Personnes" },
+        { "/_Match",                     NULL,         NULL,             0,  "<Branch>" },
+        { "/Match/_Lancer",              "<control>L", menu_runmatch,    0,  NULL },
+        { "/Match/_Tournois",            "<control>T", menu_runtournois, 0,  NULL },
+        { "/_Aide",                      NULL,         NULL,             0,  "<LastBranch>" },
+        { "/_Aide/_Bulles d'aide",       "<control>B", menu_ttip,        10, "<ToggleItem>" },
+        { "/_Aide/_A propos",            NULL,         menu_disp_about,  0,  NULL },
+};
 
 GtkWidget *create_menubar()
 {
-  GtkItemFactory *item_factory = NULL;
-  GtkAccelGroup	*accel_group  = NULL;
-  GtkWidget *widget = NULL, *ttip = NULL;
-  int nmenu_items, i;
-
-  nmenu_items = sizeof (gtk_menu_items) / sizeof (gtk_menu_items[0]);
-  accel_group = gtk_accel_group_new();
-  item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", 
-				      accel_group);
-  gtk_item_factory_create_items_ac(item_factory, nmenu_items, gtk_menu_items, 
-				   NULL, 2);
-  gtk_window_add_accel_group(GTK_WINDOW(gl_config->window), accel_group);
-  widget = gtk_item_factory_get_widget(item_factory, "<main>");
-  ttip = gtk_item_factory_get_widget_by_action(item_factory, 10);  
-  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ttip), TRUE);  
-  for (i = 0; i < NOTEBOOK_PAGE_NUM; i++)
-    gl_config->menunb[i] = gtk_item_factory_get_widget_by_action(item_factory,
-								 i + 1);  
-  gtk_widget_show(widget);
-  return widget;
+    GtkItemFactory *item_factory = NULL;
+    GtkAccelGroup *accel_group = NULL;
+    GtkWidget *widget = NULL, *ttip = NULL;
+    int nmenu_items, i;
+
+    nmenu_items = sizeof(gtk_menu_items) / sizeof(gtk_menu_items[0]);
+    accel_group = gtk_accel_group_new();
+    item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>",
+                                        accel_group);
+    gtk_item_factory_create_items_ac(item_factory, nmenu_items, gtk_menu_items,
+                                     NULL, 2);
+    gtk_window_add_accel_group(GTK_WINDOW(gl_config->window), accel_group);
+    widget = gtk_item_factory_get_widget(item_factory, "<main>");
+    ttip = gtk_item_factory_get_widget_by_action(item_factory, 10);
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ttip), TRUE);
+    for ( i = 0 ; i < NOTEBOOK_PAGE_NUM ; i++ )
+    {
+        gl_config->menunb[i] = gtk_item_factory_get_widget_by_action(item_factory,
+                                                                     i + 1);
+    }
+    gtk_widget_show(widget);
+    return widget;
 }

+ 64 - 56
meta-client/mysql.c

@@ -1,91 +1,99 @@
-/* $Id: mysql.c,v 1.5 2001/04/12 22:45:29 kilobug Exp $ */
-
 #include "mclient.h"
 
 int mysql_query_gtk(MYSQL *mysql, const char *query)
 {
-  int i;
-  GtkWidget *wi;
-  char buf[MYSQL_BUFFER_SIZE];
+    int i;
+    GtkWidget *wi;
+    char buf[MYSQL_BUFFER_SIZE];
 
-  i = mysql_query(mysql, query);
-  if (i)
+    i = mysql_query(mysql, query);
+    if ( i )
     {
-      g_snprintf(buf, MYSQL_BUFFER_SIZE, 
-		 "> %s <\n\n"
-		 "(Requète = `%s')\n", mysql_error(mysql), query);
-      wi = create_dialog("Erreur SQL", create_label(buf), NULL, " Fermer ",
-			 NULL, NULL, destroy_widget);
-      gtk_widget_show(wi);
+        g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                   "> %s <\n\n"
+                   "(Requ�te = `%s')\n", mysql_error(mysql), query);
+        wi = create_dialog("Erreur SQL", create_label(buf), NULL, " Fermer ",
+                           NULL, NULL, destroy_widget);
+        gtk_widget_show(wi);
     }
-  return i;
+    return i;
 }
 
-static MYSQL_RES *mysql_get_result_v(MYSQL *mysql, const char *query, 
-				     va_list ap)
+static MYSQL_RES *mysql_get_result_v(MYSQL *mysql, const char *query,
+                                     va_list ap)
 {
-  char mysql_buffer[MYSQL_BUFFER_SIZE];
+    char mysql_buffer[MYSQL_BUFFER_SIZE];
 
-  g_vsnprintf(mysql_buffer, MYSQL_BUFFER_SIZE, query, ap);
-  if (mysql_query_gtk(mysql, mysql_buffer))
-    return NULL;
-  return mysql_store_result(mysql);
+    g_vsnprintf(mysql_buffer, MYSQL_BUFFER_SIZE, query, ap);
+    if ( mysql_query_gtk(mysql, mysql_buffer))
+    {
+        return NULL;
+    }
+    return mysql_store_result(mysql);
 }
 
-static MYSQL_ROW mysql_get_row_v(MYSQL *mysql, const char *query, 
-				  va_list ap)
+static MYSQL_ROW mysql_get_row_v(MYSQL *mysql, const char *query,
+                                 va_list ap)
 {
-  MYSQL_ROW row;
-  static MYSQL_RES *res = NULL;
+    MYSQL_ROW row;
+    static MYSQL_RES *res = NULL;
 
-  if (res != NULL)
-    mysql_free_result(res);
-  if ((res = mysql_get_result_v(mysql, query, ap)) == NULL)
-    return NULL;
-  row = mysql_fetch_row(res);
-  return row;
+    if ( res != NULL )
+    {
+        mysql_free_result(res);
+    }
+    if (( res = mysql_get_result_v(mysql, query, ap)) == NULL )
+    {
+        return NULL;
+    }
+    row = mysql_fetch_row(res);
+    return row;
 }
 
 static char *mysql_get_str_v(MYSQL *mysql, const char *query, va_list ap)
 {
-  MYSQL_ROW row;
+    MYSQL_ROW row;
 
-  row = mysql_get_row_v(mysql, query, ap);
-  if (row == NULL)
-    return g_strdup("");
-  else
-    return g_strdup(row[0]);
+    row = mysql_get_row_v(mysql, query, ap);
+    if ( row == NULL )
+    {
+        return g_strdup("");
+    }
+    else
+    {
+        return g_strdup(row[0]);
+    }
 }
 
 int mysql_get_int(MYSQL *mysql, const char *query, ...)
 {
-  va_list ap;
-  int i;
-  char *s;
+    va_list ap;
+    int i;
+    char *s;
 
-  va_start(ap, query);
-  s = mysql_get_str_v(mysql, query, ap);
-  i = atoi(s);
-  g_free(s);
-  va_end(ap);
-  return i;
+    va_start(ap, query);
+    s = mysql_get_str_v(mysql, query, ap);
+    i = atoi(s);
+    g_free(s);
+    va_end(ap);
+    return i;
 }
 
 char *mysql_get_str(MYSQL *mysql, const char *query, ...)
 {
-  va_list ap;
-  char *s;
+    va_list ap;
+    char *s;
 
-  va_start(ap, query);
-  s = mysql_get_str_v(mysql, query, ap);
-  va_end(ap);
-  return s;
+    va_start(ap, query);
+    s = mysql_get_str_v(mysql, query, ap);
+    va_end(ap);
+    return s;
 }
 
 void mysql_do_query(MYSQL *mysql, const char *query, ...)
 {
-  va_list ap;
-  va_start(ap, query);
-  mysql_get_result_v(mysql, query, ap);
-  va_end(ap);  
+    va_list ap;
+    va_start(ap, query);
+    mysql_get_result_v(mysql, query, ap);
+    va_end(ap);
 }

+ 425 - 384
meta-client/mysql_list.c

@@ -1,298 +1,333 @@
-/* $Id: mysql_list.c,v 1.12 2001/04/20 10:25:13 kilobug Exp $ */
-
 #include "mclient.h"
 
 void mysql_list_refresh(const sql_list_t *l, const char *where)
 {
-  char *s;
-  MYSQL_RES *res;
-  MYSQL_ROW row;
-  char **tb;
-  int *p, i;
-  GdkColor *col;
-
-  if (where != NULL)
-    s = g_strconcat(l->query, " AND (", where, ")", NULL);
-  else
-    s = g_strdup(l->query);
-  if (mysql_query_gtk(gl_config->mysql, s))
-    return;
-  g_free(s);
-  res = mysql_store_result(gl_config->mysql);
-  i  = mysql_num_fields(res);
-  if (i != l->nb_fields)
+    char *s;
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+    char **tb;
+    int *p, i;
+    GdkColor *col;
+
+    if ( where != NULL )
+    {
+        s = g_strconcat(l->query, " AND (", where, ")", NULL);
+    }
+    else
+    {
+        s = g_strdup(l->query);
+    }
+    if ( mysql_query_gtk(gl_config->mysql, s))
+    {
+        return;
+    }
+    g_free(s);
+    res = mysql_store_result(gl_config->mysql);
+    i = mysql_num_fields(res);
+    if ( i != l->nb_fields )
     {
-      fprintf(stderr, 
-	      "Warning: SQL error: number of rows mismatch (%d / %d).\n",
-	      i, l->nb_fields);
-      return;
+        fprintf(stderr,
+                "Warning: SQL error: number of rows mismatch (%d / %d).\n",
+                i, l->nb_fields);
+        return;
     }
 
-  tb = g_malloc(sizeof(*tb) * (l->nb_fields - 1));
-  gtk_clist_unselect_all(l->clist);
-  gtk_clist_freeze(l->clist);
-  gtk_clist_clear(l->clist);
-  while ((row = mysql_fetch_row(res)) != NULL)
+    tb = g_malloc(sizeof(*tb) * ( l->nb_fields - 1 ));
+    gtk_clist_unselect_all(l->clist);
+    gtk_clist_freeze(l->clist);
+    gtk_clist_clear(l->clist);
+    while (( row = mysql_fetch_row(res)) != NULL )
     {
-      for (i = 1; i < l->nb_fields; i++)
-	if (l->items[i].cvt_func != NULL)
-	  tb[i - 1] = l->items[i].cvt_func(row[i], l->items[i].data);
-	else
-	  tb[i - 1] = row[i];
-      p = g_malloc(sizeof(*p));
-      *p = atoi(row[0]);
-      col = NULL;
-      if (l->color_func != NULL)
-	col = l->color_func(l, *p, l->color_func_data);
-      i = gtk_clist_append(l->clist, tb);
-      gtk_clist_set_row_data_full(l->clist, i, p, g_free);
-      if (col != NULL)
-	{
-	  gtk_clist_set_foreground(l->clist, i, col);
-	  g_free(col);
-	}
-      for (i = 1; i < l->nb_fields; i++)
-	if (l->items[i].destroy_func != NULL)
-	  l->items[i].destroy_func(tb[i - 1]);
+        for ( i = 1 ; i < l->nb_fields ; i++ )
+        {
+            if ( l->items[i].cvt_func != NULL )
+            {
+                tb[i - 1] = l->items[i].cvt_func(row[i], l->items[i].data);
+            }
+            else
+            {
+                tb[i - 1] = row[i];
+            }
+        }
+        p = g_malloc(sizeof(*p));
+        *p = atoi(row[0]);
+        col = NULL;
+        if ( l->color_func != NULL )
+        {
+            col = l->color_func(l, *p, l->color_func_data);
+        }
+        i = gtk_clist_append(l->clist, tb);
+        gtk_clist_set_row_data_full(l->clist, i, p, g_free);
+        if ( col != NULL )
+        {
+            gtk_clist_set_foreground(l->clist, i, col);
+            g_free(col);
+        }
+        for ( i = 1 ; i < l->nb_fields ; i++ )
+        {
+            if ( l->items[i].destroy_func != NULL )
+            {
+                l->items[i].destroy_func(tb[i - 1]);
+            }
+        }
     }
-  mysql_free_result(res);
-  g_free(tb);
+    mysql_free_result(res);
+    g_free(tb);
 
-  gtk_clist_thaw(l->clist);
+    gtk_clist_thaw(l->clist);
 }
 
 sql_list_t *mysql_list_make(const char *query, int nb_fields, GtkCList *clist,
-			    ...)
+                            ...)
 {
-  sql_list_t *res;
-  va_list va;
-  int i;
-
-  res = g_malloc(sizeof(*res));
-  res->query = query;
-  res->clist = clist;
-  res->color_func = NULL;
-  res->color_func_data = NULL;
-  res->nb_fields = nb_fields;
-  res->items = g_malloc(sizeof(*(res->items)) * nb_fields);
-  for (i = 0; i < nb_fields; i++)
+    sql_list_t *res;
+    va_list va;
+    int i;
+
+    res = g_malloc(sizeof(*res));
+    res->query = query;
+    res->clist = clist;
+    res->color_func = NULL;
+    res->color_func_data = NULL;
+    res->nb_fields = nb_fields;
+    res->items = g_malloc(sizeof(*( res->items )) * nb_fields);
+    for ( i = 0 ; i < nb_fields ; i++ )
     {
-      res->items[i].destroy_func = NULL;
-      res->items[i].cvt_func = NULL;
-      res->items[i].data = NULL;
+        res->items[i].destroy_func = NULL;
+        res->items[i].cvt_func = NULL;
+        res->items[i].data = NULL;
     }
-  va_start(va, clist);
-  while ((i = va_arg(va, int)) >= 0)
+    va_start(va, clist);
+    while (( i = va_arg(va,
+    { int })) >= 0)
     {
-      res->items[i].cvt_func = va_arg(va, ml_cvt_func_t *);
-      res->items[i].destroy_func = va_arg(va, void *);
-      res->items[i].data = va_arg(va, void *);
+        res->items[i].cvt_func = va_arg(va, ml_cvt_func_t * );
+        res->items[i].destroy_func = va_arg(va,
+        void *);
+        res->items[i].data = va_arg(va,
+        void *);
     }
-  va_end(va);
-  return res;
+    va_end(va);
+    return res;
 }
 
-void mysql_list_set_color_func(sql_list_t *list, ml_color_func_t *callback, 
-			       void *data)
+void mysql_list_set_color_func(sql_list_t *list, ml_color_func_t *callback,
+                               void *data)
 {
-  if (list == NULL)
-    return;
-  list->color_func = callback;
-  list->color_func_data = data;
+    if ( list == NULL )
+    {
+        return;
+    }
+    list->color_func = callback;
+    list->color_func_data = data;
 }
 
 /*
 ** Adder
 */
-static void mysql_adder_do_commit(const sql_add_t *adder, const char *before, 
-				  const char *after)
+static void mysql_adder_do_commit(const sql_add_t *adder, const char *before,
+                                  const char *after)
 {
-  char buf[MYSQL_BUFFER_SIZE], *p;
-  GSList *l;
-  sql_add_item_t *item;
-  int i;
-  char *path, *apath, *s;
+    char buf[MYSQL_BUFFER_SIZE], *p;
+    GSList *l;
+    sql_add_item_t *item;
+    int i;
+    char *path, *apath, *s;
 
-  if (adder->table == NULL)
+    if ( adder->table == NULL )
     {
-      adder->callback(NULL, adder);
-      return;
+        adder->callback(NULL, adder);
+        return;
     }
-  g_snprintf(buf, MYSQL_BUFFER_SIZE,
-	     "%s %s SET auteur=%d", before, adder->table, getuid());
-  p = buf + strlen(buf);
-  for (l = adder->items; l != NULL; l = l->next)
+    g_snprintf(buf, MYSQL_BUFFER_SIZE,
+               "%s %s SET auteur=%d", before, adder->table, getuid());
+    p = buf + strlen(buf);
+    for ( l = adder->items ; l != NULL ; l = l->next )
     {
-      item = l->data;
-      p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), ", %s=", item->field);
-      switch (item->type)
-	{
-	case sql_add_str:
-	  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), 
-			  "'%s'", gtk_entry_get_text(GTK_ENTRY(item->widget)));
-	  break;
-	case sql_add_file:
-	  path = gtk_entry_get_text(GTK_ENTRY(item->widget));
-	  if (g_path_is_absolute(path))
-	    apath = path;
-	  else
-	    {
-	      s = g_get_current_dir();
-	      apath = g_strconcat(s, G_DIR_SEPARATOR_S, path, NULL);
-	      g_free(s);
-	    }
-	  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), "'%s'", apath);
-	  if (apath != path)
-	    g_free(apath);
-	  break;
-	case sql_add_num:
-	  set_data_from_spin(item->widget, &i);
-	  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), "'%d'", i);
-	  break;
-	case sql_add_flag:
-	  set_data_from_toggle(item->widget, &i);
-	  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), "'%d'", i);
-	  break;
-	default:
-	  fprintf(stderr, 
-		  "Warning: internal error in `mysql_adder_commit'.\n");
-	}
+        item = l->data;
+        p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), ", %s=", item->field);
+        switch ( item->type )
+        {
+        case sql_add_str:
+            p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ),
+                            "'%s'", gtk_entry_get_text(GTK_ENTRY(item->widget)));
+            break;
+        case sql_add_file:
+            path = gtk_entry_get_text(GTK_ENTRY(item->widget));
+            if ( g_path_is_absolute(path))
+            {
+                apath = path;
+            }
+            else
+            {
+                s = g_get_current_dir();
+                apath = g_strconcat(s, G_DIR_SEPARATOR_S, path, NULL);
+                g_free(s);
+            }
+            p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), "'%s'", apath);
+            if ( apath != path )
+            {
+                g_free(apath);
+            }
+            break;
+        case sql_add_num:
+            set_data_from_spin(item->widget, &i);
+            p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), "'%d'", i);
+            break;
+        case sql_add_flag:
+            set_data_from_toggle(item->widget, &i);
+            p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), "'%d'", i);
+            break;
+        default:
+            fprintf(stderr,
+                    "Warning: internal error in `mysql_adder_commit'.\n");
+        }
     }
-  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), " %s", after);
-  mysql_query_gtk(gl_config->mysql, buf);
-  adder->callback(NULL, adder);
+    p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), " %s", after);
+    mysql_query_gtk(gl_config->mysql, buf);
+    adder->callback(NULL, adder);
 }
 
 static void mysql_adder_commit(GtkWidget *wid, sql_add_t *adder)
 {
-  mysql_adder_do_commit(adder, "INSERT INTO ", "");
+    mysql_adder_do_commit(adder, "INSERT INTO ", "");
 }
 
-static void mysql_adder_item_create(sql_add_item_t *item, GtkWidget *tbl, 
-				    int pos, 
-				    GtkSignalFunc activate, void *actdata,
-				    GtkSignalFunc activate2, void *actdata2)
+static void mysql_adder_item_create(sql_add_item_t *item, GtkWidget *tbl,
+                                    int pos,
+                                    GtkSignalFunc activate, void *actdata,
+                                    GtkSignalFunc activate2, void *actdata2)
 {
-  int *foo = NULL;
-  char *s;
-  GtkWidget *widget;
+    int *foo = NULL;
+    char *s;
+    GtkWidget *widget;
 
-  widget = create_label(item->label);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), widget, 0, 1, pos, pos + 1);
-  switch (item->type)
+    widget = create_label(item->label);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), widget, 0, 1, pos, pos + 1);
+    switch ( item->type )
     {
     case sql_add_str:
-      foo = item->param;
-      item->widget = create_entry(NULL, *foo);
-      gtk_table_attach_defaults(GTK_TABLE(tbl), item->widget, 
-				1, 3, pos, pos + 1);
-      gtk_signal_connect(GTK_OBJECT(item->widget), "activate", 
-			 activate, actdata);
-      gtk_signal_connect_after(GTK_OBJECT(item->widget), "activate", 
-			       activate2, actdata2);
-      break;
+        foo = item->param;
+        item->widget = create_entry(NULL, *foo);
+        gtk_table_attach_defaults(GTK_TABLE(tbl), item->widget,
+                                  1, 3, pos, pos + 1);
+        gtk_signal_connect(GTK_OBJECT(item->widget), "activate",
+                           activate, actdata);
+        gtk_signal_connect_after(GTK_OBJECT(item->widget), "activate",
+                                 activate2, actdata2);
+        break;
     case sql_add_num:
-      foo = item->param;
-      item->widget = create_spin(foo[0], foo[1], foo[2]);
-      gtk_table_attach_defaults(GTK_TABLE(tbl), item->widget, 
-				1, 3, pos, pos + 1);
-      break;
+        foo = item->param;
+        item->widget = create_spin(foo[0], foo[1], foo[2]);
+        gtk_table_attach_defaults(GTK_TABLE(tbl), item->widget,
+                                  1, 3, pos, pos + 1);
+        break;
     case sql_add_flag:
-      foo = item->param;
-      item->widget = create_check(*foo);
-      gtk_table_attach(GTK_TABLE(tbl), item->widget, 1, 3, pos, pos + 1,
-		       GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 5);
-      break;
+        foo = item->param;
+        item->widget = create_check(*foo);
+        gtk_table_attach(GTK_TABLE(tbl), item->widget, 1, 3, pos, pos + 1,
+                         GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 5);
+        break;
     case sql_add_file:
-      s = item->param;
-      item->widget = create_entry(NULL, 200);
-      gtk_table_attach_defaults(GTK_TABLE(tbl), item->widget, 
-				1, 2, pos, pos + 1);
-      widget = create_filesel_button("Parcourir", "Parcourir...", 
-				     GTK_ENTRY(item->widget));
-      gtk_tooltips_set_tip(gl_config->tooltips, widget, 
-			   "Choisir le fichier...", "");
-      gtk_table_attach(GTK_TABLE(tbl), widget, 2, 3, pos, pos + 1,
-		       GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 0);
-      gtk_signal_connect(GTK_OBJECT(item->widget), "activate", 
-			 activate, actdata);
-      gtk_signal_connect_after(GTK_OBJECT(item->widget), "activate", 
-			       activate2, actdata2);
-      break;
+        s = item->param;
+        item->widget = create_entry(NULL, 200);
+        gtk_table_attach_defaults(GTK_TABLE(tbl), item->widget,
+                                  1, 2, pos, pos + 1);
+        widget = create_filesel_button("Parcourir", "Parcourir...",
+                                       GTK_ENTRY(item->widget));
+        gtk_tooltips_set_tip(gl_config->tooltips, widget,
+                             "Choisir le fichier...", "");
+        gtk_table_attach(GTK_TABLE(tbl), widget, 2, 3, pos, pos + 1,
+                         GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 0);
+        gtk_signal_connect(GTK_OBJECT(item->widget), "activate",
+                           activate, actdata);
+        gtk_signal_connect_after(GTK_OBJECT(item->widget), "activate",
+                                 activate2, actdata2);
+        break;
     default:
-      fprintf(stderr, "Warning: internal error in `make_mysql_adder'.\n");
+        fprintf(stderr, "Warning: internal error in `make_mysql_adder'.\n");
     }
-  gtk_tooltips_set_tip(gl_config->tooltips, item->widget, item->tooltip, "");
+    gtk_tooltips_set_tip(gl_config->tooltips, item->widget, item->tooltip, "");
 }
 
 static sql_add_item_t *mysql_adder_item_get(va_list *va)
 {
-  int *foo = NULL;
-  sql_add_item_t *item;
-  char *s;
-
-  item = g_malloc(sizeof(*item));
-  item->label = va_arg(*va, const char *);
-  item->field = va_arg(*va, const char *);
-  item->tooltip = va_arg(*va, const char *);
-  item->type = va_arg(*va, int);
-  switch (item->type)
+    int *foo = NULL;
+    sql_add_item_t *item;
+    char *s;
+
+    item = g_malloc(sizeof(*item));
+    item->label = va_arg(*va,
+    const char *);
+    item->field = va_arg(*va,
+    const char *);
+    item->tooltip = va_arg(*va,
+    const char *);
+    item->type = va_arg(*va,
+    int);
+    switch ( item->type )
     {
     case sql_add_str:
-      foo = item->param = g_malloc(sizeof(int));
-      *foo = va_arg(*va, int);
-      break;
+        foo = item->param = g_malloc(sizeof(int));
+        *foo = va_arg(*va,
+        int);
+        break;
     case sql_add_num:
-      foo = item->param = g_malloc(sizeof(int) * 3);
-      foo[0] = va_arg(*va, int);
-      foo[1] = va_arg(*va, int);
-      foo[2] = va_arg(*va, int);
-      break;
+        foo = item->param = g_malloc(sizeof(int) * 3);
+        foo[0] = va_arg(*va,
+        int);
+        foo[1] = va_arg(*va,
+        int);
+        foo[2] = va_arg(*va,
+        int);
+        break;
     case sql_add_flag:
-      foo = item->param = g_malloc(sizeof(int));
-      *foo = va_arg(*va, int);
-      break;
+        foo = item->param = g_malloc(sizeof(int));
+        *foo = va_arg(*va,
+        int);
+        break;
     case sql_add_file:
-      s = va_arg(*va, char *);
-      item->param = s;
-      break;
+        s = va_arg(*va,
+        char *);
+        item->param = s;
+        break;
     }
-  return item;
+    return item;
 }
 
 sql_add_t *mysql_adder_make(const char *table, const char *title,
-			    GtkSignalFunc callback, int nb, ...)
+                            GtkSignalFunc callback, int nb, ...)
 {
-  sql_add_t *res;
-  GtkWidget *tbl;
-  int i;
-  va_list va;
-  sql_add_item_t *item;
-
-  va_start(va, nb);
-  res = g_malloc(sizeof(*res));
-  res->table = table;
-  res->items = NULL;
-  res->callback = callback;
-
-  /* Main box */
-  tbl = gtk_table_new(3, nb, FALSE);
-  gtk_widget_show(tbl);
-  res->widget = create_dialog(title, tbl, " Valider ", " Annuler ", 
-			      mysql_adder_commit, res, hide_widget);
-
-  /* Entrys */
-  for (i = 0; i < nb; i++)
+    sql_add_t *res;
+    GtkWidget *tbl;
+    int i;
+    va_list va;
+    sql_add_item_t *item;
+
+    va_start(va, nb);
+    res = g_malloc(sizeof(*res));
+    res->table = table;
+    res->items = NULL;
+    res->callback = callback;
+
+    /* Main box */
+    tbl = gtk_table_new(3, nb, FALSE);
+    gtk_widget_show(tbl);
+    res->widget = create_dialog(title, tbl, " Valider ", " Annuler ",
+                                mysql_adder_commit, res, hide_widget);
+
+    /* Entrys */
+    for ( i = 0 ; i < nb ; i++ )
     {
-      item = mysql_adder_item_get(&va);
-      mysql_adder_item_create(item, tbl, i, mysql_adder_commit, res, 
-			      hide_widget, res->widget);
-      res->items = g_slist_prepend(res->items, item);
+        item = mysql_adder_item_get(&va);
+        mysql_adder_item_create(item, tbl, i, mysql_adder_commit, res,
+                                hide_widget, res->widget);
+        res->items = g_slist_prepend(res->items, item);
     }
 
 
-  va_end(va);
-  return res;
+    va_end(va);
+    return res;
 }
 
 /*
@@ -300,98 +335,104 @@ sql_add_t *mysql_adder_make(const char *table, const char *title,
 */
 static void mysql_query_callback(GtkWidget *wid, const char *query)
 {
-  mysql_query_gtk(gl_config->mysql, query);
+    mysql_query_gtk(gl_config->mysql, query);
 }
 
 static void mysql_list_remove_confirm(char *query, int nb,
-				      GtkSignalFunc refresh_callback)
+                                      GtkSignalFunc refresh_callback)
 {
-  GtkWidget *dialog, *widget, *hbox;
-  GtkAccelGroup *accel_group;
-  char buf[MYSQL_BUFFER_SIZE];
-
-  /* Main box */
-  dialog = gtk_dialog_new();
-  gtk_widget_hide(dialog);
-  gtk_signal_connect(GTK_OBJECT(dialog), "destroy", 
-		     GTK_SIGNAL_FUNC(gtk_widget_destroy), NULL);
-  gtk_signal_connect_after(GTK_OBJECT(dialog), "destroy", 
-			   GTK_SIGNAL_FUNC(free_callback), query);
-  gtk_window_set_title(GTK_WINDOW(dialog), "Confirmation de suppression");
-  gtk_container_set_border_width(GTK_CONTAINER(&(GTK_DIALOG(dialog)->window)),
-				 7);  
-  accel_group = gtk_accel_group_new();
-  gtk_window_add_accel_group(GTK_WINDOW(&(GTK_DIALOG(dialog)->window)), 
-			     accel_group);
-
-  /* Buttons */
-  hbox = gtk_hbox_new(FALSE, 3);
-  gtk_widget_show(hbox);
-  widget = gtk_button_new_with_label(" Oui ");
-  gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
-                              GTK_ACCEL_VISIBLE);
-  gtk_widget_show(widget);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(mysql_query_callback), query);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(refresh_callback), NULL);
-  gtk_signal_connect_after(GTK_OBJECT(widget), "clicked", 
-			   GTK_SIGNAL_FUNC(destroy_widget), dialog); 
-  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-  widget = gtk_button_new_with_label(" Non ");
-  gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Escape, 0,
-                              GTK_ACCEL_VISIBLE);
-  gtk_widget_show(widget);
-  gtk_signal_connect_after(GTK_OBJECT(widget), "clicked", 
-			   GTK_SIGNAL_FUNC(destroy_widget), dialog); 
-  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), hbox, TRUE,
-		     TRUE, 9);
-
-  /* Message */
-  if (nb > 1)
-    g_snprintf(buf, MYSQL_BUFFER_SIZE, 
-	       "Es-tu sûr de vouloir effacer ces %d éléments ?", nb);
-  else
-    g_snprintf(buf, MYSQL_BUFFER_SIZE, 
-	       "Es-tu sûr de vouloir effacer cet élément ?");
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), create_label(buf), 
-		     TRUE, TRUE, 9);
-  gtk_widget_show(dialog);
+    GtkWidget *dialog, *widget, *hbox;
+    GtkAccelGroup *accel_group;
+    char buf[MYSQL_BUFFER_SIZE];
+
+    /* Main box */
+    dialog = gtk_dialog_new();
+    gtk_widget_hide(dialog);
+    gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
+                       GTK_SIGNAL_FUNC(gtk_widget_destroy), NULL);
+    gtk_signal_connect_after(GTK_OBJECT(dialog), "destroy",
+                             GTK_SIGNAL_FUNC(free_callback), query);
+    gtk_window_set_title(GTK_WINDOW(dialog), "Confirmation de suppression");
+    gtk_container_set_border_width(GTK_CONTAINER(&( GTK_DIALOG(dialog)->window )),
+                                   7);
+    accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(&( GTK_DIALOG(dialog)->window )),
+                               accel_group);
+
+    /* Buttons */
+    hbox = gtk_hbox_new(FALSE, 3);
+    gtk_widget_show(hbox);
+    widget = gtk_button_new_with_label(" Oui ");
+    gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Return, 0,
+                               GTK_ACCEL_VISIBLE);
+    gtk_widget_show(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(mysql_query_callback), query);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(refresh_callback), NULL);
+    gtk_signal_connect_after(GTK_OBJECT(widget), "clicked",
+                             GTK_SIGNAL_FUNC(destroy_widget), dialog);
+    gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+    widget = gtk_button_new_with_label(" Non ");
+    gtk_widget_add_accelerator(widget, "clicked", accel_group, GDK_Escape, 0,
+                               GTK_ACCEL_VISIBLE);
+    gtk_widget_show(widget);
+    gtk_signal_connect_after(GTK_OBJECT(widget), "clicked",
+                             GTK_SIGNAL_FUNC(destroy_widget), dialog);
+    gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), hbox, TRUE,
+                       TRUE, 9);
+
+    /* Message */
+    if ( nb > 1 )
+    {
+        g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                   "Es-tu s�r de vouloir effacer ces %d �l�ments ?", nb);
+    }
+    else
+    {
+        g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                   "Es-tu s�r de vouloir effacer cet �l�ment ?");
+    }
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), create_label(buf),
+                       TRUE, TRUE, 9);
+    gtk_widget_show(dialog);
 }
 
-void mysql_list_remove(const char *table, GtkCList *clist, 
-		       GtkSignalFunc refresh_callback)
+void mysql_list_remove(const char *table, GtkCList *clist,
+                       GtkSignalFunc refresh_callback)
 {
-  GSList *valid = NULL, *sl;
-  GList *l;
-  int id, nb;
-  char *buf, *p;
+    GSList *valid = NULL, *sl;
+    GList *l;
+    int id, nb;
+    char *buf, *p;
 
-  for (l = clist->selection; l != NULL; l = l->next)
+    for ( l = clist->selection ; l != NULL ; l = l->next )
     {
-      id = *((int *) gtk_clist_get_row_data(clist, GPOINTER_TO_INT(l->data)));
-      if ((gl_config->staff) || 
-	  (mysql_get_int(gl_config->mysql,
-			 "SELECT auteur FROM %s WHERE id=%d", 
-			 table, id) == getuid()))
-	valid = g_slist_prepend(valid, GINT_TO_POINTER(id));
+        id = *((int *) gtk_clist_get_row_data(clist, GPOINTER_TO_INT(l->data)));
+        if (( gl_config->staff ) ||
+            ( mysql_get_int(gl_config->mysql,
+                            "SELECT auteur FROM %s WHERE id=%d",
+                            table, id) == getuid()))
+        {
+            valid = g_slist_prepend(valid, GINT_TO_POINTER(id));
+        }
     }
-  nb = g_slist_length(valid);
-  if (nb != 0)
-    {     
-      p = buf = g_malloc(MYSQL_BUFFER_SIZE);
-      p += g_snprintf(buf, MYSQL_BUFFER_SIZE, 
-		      "UPDATE %s SET actif=0, nom=CONCAT('Z_', id, '_', nom) "
-		      "WHERE 0", 
-		      table);
-      for (sl = valid; sl != NULL; sl = sl->next)
-	{
-	  id = GPOINTER_TO_INT(sl->data);
-	  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), " OR id=%d", id);  
-	}
-      g_slist_free(valid);
-      mysql_list_remove_confirm(buf, nb, refresh_callback);
+    nb = g_slist_length(valid);
+    if ( nb != 0 )
+    {
+        p = buf = g_malloc(MYSQL_BUFFER_SIZE);
+        p += g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                        "UPDATE %s SET actif=0, nom=CONCAT('Z_', id, '_', nom) "
+                        "WHERE 0",
+                        table);
+        for ( sl = valid ; sl != NULL ; sl = sl->next )
+        {
+            id = GPOINTER_TO_INT(sl->data);
+            p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), " OR id=%d", id);
+        }
+        g_slist_free(valid);
+        mysql_list_remove_confirm(buf, nb, refresh_callback);
     }
 }
 
@@ -400,108 +441,108 @@ void mysql_list_remove(const char *table, GtkCList *clist,
 */
 static sql_add_item_t *mysql_adder_item_duplicate(const sql_add_item_t *foo)
 {
-  sql_add_item_t *item;
+    sql_add_item_t *item;
 
-  item = g_malloc(sizeof(*item));
-  memcpy(item, foo, sizeof(*item));
-  return item;
+    item = g_malloc(sizeof(*item));
+    memcpy(item, foo, sizeof(*item));
+    return item;
 }
 
-static void mysql_adder_item_set_value(sql_add_item_t *item, 
-				       const char *table, int id)
+static void mysql_adder_item_set_value(sql_add_item_t *item,
+                                       const char *table, int id)
 {
-  char *s;
-  int i;
+    char *s;
+    int i;
 
-  switch (item->type)
+    switch ( item->type )
     {
     case sql_add_file:
     case sql_add_str:
-      s = mysql_get_str(gl_config->mysql, "SELECT %s FROM %s WHERE id=%d",
-			item->field, table, id);
-      gtk_entry_set_text(GTK_ENTRY(item->widget), s);
-      g_free(s);
-      break;
+        s = mysql_get_str(gl_config->mysql, "SELECT %s FROM %s WHERE id=%d",
+                          item->field, table, id);
+        gtk_entry_set_text(GTK_ENTRY(item->widget), s);
+        g_free(s);
+        break;
     case sql_add_num:
-      i = mysql_get_int(gl_config->mysql, "SELECT %s FROM %s WHERE id=%d",
-			item->field, table, id);
-      gtk_spin_button_set_value(GTK_SPIN_BUTTON(item->widget), i);
-      break;
+        i = mysql_get_int(gl_config->mysql, "SELECT %s FROM %s WHERE id=%d",
+                          item->field, table, id);
+        gtk_spin_button_set_value(GTK_SPIN_BUTTON(item->widget), i);
+        break;
     case sql_add_flag:
-      i = mysql_get_int(gl_config->mysql, "SELECT %s FROM %s WHERE id=%d",
-			item->field, table, id);
-      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item->widget), i);
-      break;
+        i = mysql_get_int(gl_config->mysql, "SELECT %s FROM %s WHERE id=%d",
+                          item->field, table, id);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item->widget), i);
+        break;
     }
 }
 
 static void mysql_edit_commit(GtkWidget *wid, sql_add_t *adder)
 {
-  char buf[MYSQL_BUFFER_SIZE];
+    char buf[MYSQL_BUFFER_SIZE];
 
-  g_snprintf(buf, MYSQL_BUFFER_SIZE, " WHERE id=%d", adder->id);
-  mysql_adder_do_commit(adder, "UPDATE ", buf);  
+    g_snprintf(buf, MYSQL_BUFFER_SIZE, " WHERE id=%d", adder->id);
+    mysql_adder_do_commit(adder, "UPDATE ", buf);
 }
 
 static void mysql_edit_free(sql_add_t *adder)
 {
-  g_slist_free(adder->items);
-  g_free(adder);
+    g_slist_free(adder->items);
+    g_free(adder);
 }
 
 static void mysql_edit_dialog(const char *title, const sql_add_t *adder,
-			      GtkSignalFunc refresh_callback,
-			      int id)
+                              GtkSignalFunc refresh_callback,
+                              int id)
 {
-  sql_add_t *res;
-  GSList *l;
-  GtkWidget *tbl;
-  sql_add_item_t *item;
-  int i;
-
-  res = g_malloc(sizeof(*res));
-  res->table = adder->table;
-  res->id = id;
-  res->callback = refresh_callback;
-  res->items = NULL;
-
-  /* Main box */
-  tbl = gtk_table_new(3, g_slist_length(adder->items), FALSE);
-  gtk_widget_show(tbl);
-  res->widget = create_dialog(title, tbl, " Valider ", " Annuler ", 
-			      mysql_edit_commit, res, destroy_widget);
-  gtk_object_set_data_full(GTK_OBJECT(res->widget), "42", res, 
-			   (GtkDestroyNotify) mysql_edit_free);
-  gtk_widget_show(res->widget);
-
-  /* Entrys */
-  for (i = 0, l = adder->items; l != NULL; l = l->next, i++)
+    sql_add_t *res;
+    GSList *l;
+    GtkWidget *tbl;
+    sql_add_item_t *item;
+    int i;
+
+    res = g_malloc(sizeof(*res));
+    res->table = adder->table;
+    res->id = id;
+    res->callback = refresh_callback;
+    res->items = NULL;
+
+    /* Main box */
+    tbl = gtk_table_new(3, g_slist_length(adder->items), FALSE);
+    gtk_widget_show(tbl);
+    res->widget = create_dialog(title, tbl, " Valider ", " Annuler ",
+                                mysql_edit_commit, res, destroy_widget);
+    gtk_object_set_data_full(GTK_OBJECT(res->widget), "42", res,
+                             (GtkDestroyNotify) mysql_edit_free);
+    gtk_widget_show(res->widget);
+
+    /* Entrys */
+    for ( i = 0, l = adder->items ; l != NULL ; l = l->next, i++ )
     {
-      item = mysql_adder_item_duplicate(l->data);
-      mysql_adder_item_create(item, tbl, i, mysql_edit_commit, res, 
-			      destroy_widget, res->widget);
-      mysql_adder_item_set_value(item, adder->table, id);
-      res->items = g_slist_prepend(res->items, item);
+        item = mysql_adder_item_duplicate(l->data);
+        mysql_adder_item_create(item, tbl, i, mysql_edit_commit, res,
+                                destroy_widget, res->widget);
+        mysql_adder_item_set_value(item, adder->table, id);
+        res->items = g_slist_prepend(res->items, item);
     }
 }
 
-void mysql_list_edit(const char *title, const GtkCList *sel, 
-		     const sql_add_t *adder, 
-		     GtkSignalFunc refresh_callback)
+void mysql_list_edit(const char *title, const GtkCList *sel,
+                     const sql_add_t *adder,
+                     GtkSignalFunc refresh_callback)
 {
-  const GList *l;
-  int id;
+    const GList *l;
+    int id;
 
-  for (l = sel->selection; l != NULL; l = l->next)
+    for ( l = sel->selection ; l != NULL ; l = l->next )
     {
-      id = *((int *) gtk_clist_get_row_data(GTK_CLIST(sel), 
-					    GPOINTER_TO_INT(l->data)));
-      if ((gl_config->staff) || 
-	  (getuid() == mysql_get_int(gl_config->mysql, 
-				     "SELECT auteur FROM %s WHERE id=%d",
-				     adder->table, id)))
-	{
-	  mysql_edit_dialog(title, adder, refresh_callback, id);
-	}
+        id = *((int *) gtk_clist_get_row_data(GTK_CLIST(sel),
+                                              GPOINTER_TO_INT(l->data)));
+        if (( gl_config->staff ) ||
+            ( getuid() == mysql_get_int(gl_config->mysql,
+                                        "SELECT auteur FROM %s WHERE id=%d",
+                                        adder->table, id)))
+        {
+            mysql_edit_dialog(title, adder, refresh_callback, id);
+        }
     }
 }

+ 557 - 495
meta-client/run_match.c

@@ -1,564 +1,626 @@
-/* $Id: run_match.c,v 1.25 2001/05/06 01:23:05 kilobug Exp $ */
-
 #include "mclient.h"
 
-#define ALLOWED_CHARS "_+-$&*!@#~.éáàèëïûôêîìä"
+#define ALLOWED_CHARS "_+-$&*!@#~.������������"
 
 typedef struct _player_t
 {
-  int id;
-  float score;
-  GdkColor *color;
+    int id;
+    float score;
+    GdkColor *color;
 } player_t;
 
 typedef struct _match_t
 {
-  GtkWidget *gfx, *port, *cmd, *public, *turns;
-  int mapid;
-  player_t *players;
-  GtkWidget **wids;
+    GtkWidget *gfx, *port, *cmd, *public, *turns;
+    int mapid;
+    player_t *players;
+    GtkWidget **wids;
 } match_t;
 
 typedef struct _rmatch_t
 {
-  GtkWidget *dialog, *textarea;
-  int fd;
-  int pid, mysql_id;
-  player_t *players;
-  int nbp;
-  int gdki;
-  char *buf;
+    GtkWidget *dialog, *textarea;
+    int fd;
+    int pid, mysql_id;
+    player_t *players;
+    int nbp;
+    int gdki;
+    char *buf;
 } rmatch_t;
 
-static void kill_match(GtkWidget *wi, rmatch_t*rm)
+static void kill_match(GtkWidget *wi, rmatch_t *rm)
 {
-  if (rm->pid > 0)
-    kill(rm->pid, SIGUSR2);
+    if ( rm->pid > 0 )
+    {
+        kill(rm->pid, SIGUSR2);
+    }
 }
 
-static gboolean match_display_line(rmatch_t *rm, const char *buf, 
-				   gboolean force);
+static bool match_display_line(rmatch_t *rm, const char *buf,
+                                   bool force);
 
 static void match_fetch_player(player_t *players, int num, int nbp)
 {
-  int i, class = 1;
-
-  if (gl_config->staff && (num > 0) && (nbp > 1))
-    {
-      for (i = 1; i <= nbp; i++)
-	if (players[i].score > players[num].score)
-	  class *= 2;      
-      i = nbp * 100 / class;
-      mysql_do_query(gl_config->mysql, 
-		     "UPDATE Champions "
-		     "SET nbmap=nbmap+1, total=total+%d "
-		     "WHERE id=%d",
-		     i, players[num].id);
-      mysql_do_query(gl_config->mysql,
-		     "UPDATE Champions "
-		     "SET score=total/nbmap, best=GREATEST(best, %f) "
-		     "WHERE id=%d", players[num].score, players[num].id);
-    }
-  g_free(players[num].color);
+    int i, class = 1;
+
+    if ( gl_config->staff && ( num > 0 ) && ( nbp > 1 ))
+    {
+        for ( i = 1 ; i <= nbp ; i++ )
+        {
+            if ( players[i].score > players[num].score )
+            {
+                class *= 2;
+            }
+        }
+        i = nbp * 100 / class;
+        mysql_do_query(gl_config->mysql,
+                       "UPDATE Champions "
+                       "SET nbmap=nbmap+1, total=total+%d "
+                       "WHERE id=%d",
+                       i, players[num].id);
+        mysql_do_query(gl_config->mysql,
+                       "UPDATE Champions "
+                       "SET score=total/nbmap, best=GREATEST(best, %f) "
+                       "WHERE id=%d", players[num].score, players[num].id);
+    }
+    g_free(players[num].color);
 }
 
-static void match_end(GtkWidget *wi, rmatch_t*rm)
+static void match_end(GtkWidget *wi, rmatch_t *rm)
 {
-  int i;
-
-  gdk_input_remove(rm->gdki);
-  match_display_line(rm, "<server> Match terminé.\n", FALSE);
-  match_display_line(rm, "\n", TRUE);
-  close(rm->fd);
-  g_free(rm->buf);
-  for (i = 0; i <= rm->nbp; i++)
-    match_fetch_player(rm->players, i, rm->nbp);
-  g_free(rm->players);
+    int i;
+
+    gdk_input_remove(rm->gdki);
+    match_display_line(rm, "<server> Match termin�.\n", FALSE);
+    match_display_line(rm, "\n", TRUE);
+    close(rm->fd);
+    g_free(rm->buf);
+    for ( i = 0 ; i <= rm->nbp ; i++ )
+    {
+        match_fetch_player(rm->players, i, rm->nbp);
+    }
+    g_free(rm->players);
 }
 
 static void kill_match_window(GtkWidget *wi, rmatch_t *rm)
 {
-  gtk_widget_destroy(rm->dialog);
-  rm->dialog = NULL;
-  rm->textarea = NULL;
+    gtk_widget_destroy(rm->dialog);
+    rm->dialog = NULL;
+    rm->textarea = NULL;
 }
 
 static void match_check_score(rmatch_t *rm, const char *buf)
 {
-  int i;
-  float f;
-  char *s;
-
-  if (strncmp(buf, "<server> Player ", 16))
-    return;
-  i = strtol(buf + 16, &s, 10);
-  s += 3;
-  f = atof(s);
-  mysql_do_query(gl_config->mysql, 
-		 "INSERT INTO Scores SET champion=%d, score='%f', match_id=%d",
-		 rm->players[i].id, f, rm->mysql_id);
-  rm->players[i].score = f;
+    int i;
+    float f;
+    char *s;
+
+    if ( strncmp(buf, "<server> Player ", 16))
+    {
+        return;
+    }
+    i = strtol(buf + 16, &s, 10);
+    s += 3;
+    f = atof(s);
+    mysql_do_query(gl_config->mysql,
+                   "INSERT INTO Scores SET champion=%d, score='%f', match_id=%d",
+                   rm->players[i].id, f, rm->mysql_id);
+    rm->players[i].score = f;
 }
 
 static void match_check_bouvier(rmatch_t *rm, const char *buf)
 {
-  const char *p;
-  char *q;
-  int i;
-  char b[MYSQL_BUFFER_SIZE];
-
-  p = strchr(buf, '(');
-  if (p == NULL)
-    return;
-  p++;
-  i = strtol(p, &q, 10);
-  if (strcmp(q, ")> Bravo, tu as gagne un tour de patio!\n"))
-    return;
-  q = mysql_get_str(gl_config->mysql, 
-		    "SELECT b.login FROM Bitmaps b, Champions c "
-		    "WHERE c.id=%d AND c.auteur = b.id", rm->players[i].id);
-  snprintf(b, MYSQL_BUFFER_SIZE, 
-	   "ns_send_msg %s 'Bravo, tu as gagne un tour de patio!'",
-	   q);
-  system(b);
-  snprintf(b, MYSQL_BUFFER_SIZE, 
-	   "echo '%s a gagne un tour de patio!' | mail bouvie_p -s Bouvieur "
-	   "-c prolo",
-	   q);
-  system(b);
-  g_free(q);
+    const char *p;
+    char *q;
+    int i;
+    char b[MYSQL_BUFFER_SIZE];
+
+    p = strchr(buf, '(');
+    if ( p == NULL )
+    {
+        return;
+    }
+    p++;
+    i = strtol(p, &q, 10);
+    if ( strcmp(q, ")> Bravo, tu as gagne un tour de patio!\n"))
+    {
+        return;
+    }
+    q = mysql_get_str(gl_config->mysql,
+                      "SELECT b.login FROM Bitmaps b, Champions c "
+                      "WHERE c.id=%d AND c.auteur = b.id", rm->players[i].id);
+    snprintf(b, MYSQL_BUFFER_SIZE,
+             "ns_send_msg %s 'Bravo, tu as gagne un tour de patio!'",
+             q);
+    system(b);
+    snprintf(b, MYSQL_BUFFER_SIZE,
+             "echo '%s a gagne un tour de patio!' | mail bouvie_p -s Bouvieur "
+             "-c prolo",
+             q);
+    system(b);
+    g_free(q);
 }
 
-static gboolean match_display_line(rmatch_t *rm, const char *buf, 
-				   gboolean force)
+static bool match_display_line(rmatch_t *rm, const char *buf,
+                                   bool force)
 {
-  char *p;
-  int id;
-  static int last_id = -42;
-  static char *buf2 = NULL;
-  
-  if (!strcmp(buf, "Bye!\n"))
-    {
-      match_end(NULL, rm);
-      return FALSE;
-    }
-  match_check_score(rm, buf);
-  match_check_bouvier(rm, buf);
-  if (rm->textarea == NULL)
+    char *p;
+    int id;
+    static int last_id = -42;
+    static char *buf2 = NULL;
+
+    if ( !strcmp(buf, "Bye!\n"))
+    {
+        match_end(NULL, rm);
+        return FALSE;
+    }
+    match_check_score(rm, buf);
+    match_check_bouvier(rm, buf);
+    if ( rm->textarea == NULL )
+    {
+        return TRUE;
+    }
+    p = strchr(buf, '(');
+    if ( p == NULL )
+    {
+        id = 0;
+    }
+    else
+    {
+        id = atoi(p + 1);
+    }
+    if ( id > rm->nbp )
+    {
+        id = 0;
+    }
+
+    if ( id == 0 )
+    {
+        force = TRUE;
+    }
+
+    if (( id == last_id ) && ( !force ))
+    {
+        p = buf2;
+        buf2 = g_strconcat(p, buf, NULL);
+        g_free(p);
+    }
+    else
+    {
+        if ( buf2 != NULL )
+        {
+            gtk_text_insert(GTK_TEXT(rm->textarea), NULL,
+                            rm->players[last_id].color,
+                            NULL, buf2, -1);
+            g_free(buf2);
+        }
+        buf2 = g_strdup(buf);
+        last_id = id;
+    }
     return TRUE;
-  p = strchr(buf, '(');
-  if (p == NULL)
-    id = 0;
-  else
-    id = atoi(p + 1);
-  if (id > rm->nbp)
-    id = 0;
-
-  if (id == 0)
-    force = TRUE;
-
-  if ((id == last_id) && (!force))
-    {
-      p = buf2;
-      buf2 = g_strconcat(p, buf, NULL);
-      g_free(p);
-    }
-  else
-    {
-      if (buf2 != NULL)
-	{
-	  gtk_text_insert(GTK_TEXT(rm->textarea), NULL, 
-			  rm->players[last_id].color, 
-			  NULL, buf2, -1);
-	  g_free(buf2);
-	}
-      buf2 = g_strdup(buf);
-      last_id = id;
-    }
-  return TRUE;
 }
 
 static void match_get_data(rmatch_t *rm, int fd, GdkInputCondition foo)
 {
-  char buf[MYSQL_BUFFER_SIZE], *s, *p;
-  int sz, l;
-  gboolean r;
-  GtkAdjustment *adj;
-
-  if (rm == NULL)
-    return;
-  sz = read(fd, buf, MYSQL_BUFFER_SIZE - 1);
-  if (sz == -1)
-    {
-      match_end(NULL, rm);
-      return;
-    }
-  buf[sz] = 0;
-  s = g_strconcat(rm->buf, buf, NULL);
-  g_free(rm->buf);
-  rm->buf = s;
-
-  if (rm->textarea != NULL)
-    {
-      gtk_text_freeze(GTK_TEXT(rm->textarea));
-      l = gtk_text_get_length(GTK_TEXT(rm->textarea));
-      l -= 5000;
-      if (l > 0)
-	{
-	  while ((GTK_TEXT_INDEX(GTK_TEXT(rm->textarea), l) != '\n') && l > 0)
-	    l--;
-	  if (l > 0)
-	    {
-	      gtk_text_set_point(GTK_TEXT(rm->textarea), 0);
-	      gtk_text_forward_delete(GTK_TEXT(rm->textarea), l);
-	      gtk_text_set_point(GTK_TEXT(rm->textarea), 
-				 gtk_text_get_length(GTK_TEXT(rm->textarea)));
-	    }
-	}
-    }
-
-  while ((p = strchr(rm->buf, '\n')) != NULL)
-    {
-      s = rm->buf;
-      rm->buf = g_strdup(p + 1);
-      p[1] = 0;
-      r = match_display_line(rm, s, FALSE);
-      g_free(s);
-      if (!r)
-	break;
-    }      
-
-  if (rm->textarea != NULL)
-    {
-      gtk_text_thaw(GTK_TEXT(rm->textarea));  
-      adj = GTK_TEXT(rm->textarea)->vadj;
-      gtk_adjustment_set_value(adj, adj->upper);
+    char buf[MYSQL_BUFFER_SIZE], *s, *p;
+    int sz, l;
+    bool r;
+    GtkAdjustment *adj;
+
+    if ( rm == NULL )
+    {
+        return;
+    }
+    sz = read(fd, buf, MYSQL_BUFFER_SIZE - 1);
+    if ( sz == -1 )
+    {
+        match_end(NULL, rm);
+        return;
+    }
+    buf[sz] = 0;
+    s = g_strconcat(rm->buf, buf, NULL);
+    g_free(rm->buf);
+    rm->buf = s;
+
+    if ( rm->textarea != NULL )
+    {
+        gtk_text_freeze(GTK_TEXT(rm->textarea));
+        l = gtk_text_get_length(GTK_TEXT(rm->textarea));
+        l -= 5000;
+        if ( l > 0 )
+        {
+            while (( GTK_TEXT_INDEX(GTK_TEXT(rm->textarea), l) != '\n' ) && l > 0 )
+            {
+                l--;
+            }
+            if ( l > 0 )
+            {
+                gtk_text_set_point(GTK_TEXT(rm->textarea), 0);
+                gtk_text_forward_delete(GTK_TEXT(rm->textarea), l);
+                gtk_text_set_point(GTK_TEXT(rm->textarea),
+                                   gtk_text_get_length(GTK_TEXT(rm->textarea)));
+            }
+        }
+    }
+
+    while (( p = strchr(rm->buf, '\n')) != NULL )
+    {
+        s = rm->buf;
+        rm->buf = g_strdup(p + 1);
+        p[1] = 0;
+        r = match_display_line(rm, s, FALSE);
+        g_free(s);
+        if ( !r )
+        {
+            break;
+        }
+    }
+
+    if ( rm->textarea != NULL )
+    {
+        gtk_text_thaw(GTK_TEXT(rm->textarea));
+        adj = GTK_TEXT(rm->textarea)->vadj;
+        gtk_adjustment_set_value(adj, adj->upper);
     }
 }
 
 static int my_creneau(int val)
 {
-  if (val >= 0)
-      return CLAMP((120 - val) * 0xFF / 120, 0, 0xFF);
-  else
-      return CLAMP((120 + val) * 0xFF / 120, 0, 0xFF);
+    if ( val >= 0 )
+    {
+        return CLAMP(( 120 - val ) * 0xFF / 120, 0, 0xFF);
+    }
+    else
+    {
+        return CLAMP(( 120 + val ) * 0xFF / 120, 0, 0xFF);
+    }
 }
 
 static GdkColor *create_player_color(int i, int nb)
 {
-  int	angle;
-  GdkColor *col;
-
-  col = g_malloc(sizeof(*col));
-  col->pixel = 0;
-  angle = (360 * i) / nb; /* position => angle dans spectre */
-  if (angle > 180)
-    angle = angle - 360;
-  col->red = my_creneau(angle) * 128;
-  col->green = my_creneau(angle - 120) * 128;
-  col->blue = my_creneau(angle + 120) * 128;
-  gdk_colormap_alloc_color(gdk_colormap_get_system(), col, TRUE, TRUE);
-  return col;
+    int angle;
+    GdkColor *col;
+
+    col = g_malloc(sizeof(*col));
+    col->pixel = 0;
+    angle = ( 360 * i ) / nb; /* position => angle dans spectre */
+    if ( angle > 180 )
+    {
+        angle = angle - 360;
+    }
+    col->red = my_creneau(angle) * 128;
+    col->green = my_creneau(angle - 120) * 128;
+    col->blue = my_creneau(angle + 120) * 128;
+    gdk_colormap_alloc_color(gdk_colormap_get_system(), col, TRUE, TRUE);
+    return col;
 }
 
-static void create_listener(int fd, int pid, int nbp, int mysql_id, 
-			    int *play_ids)
+static void create_listener(int fd, int pid, int nbp, int mysql_id,
+                            int *play_ids)
 {
-  rmatch_t *rm;
-  GtkWidget *sw, *dial, *widget, *hbox;
-  GtkScrolledWindow *scrw;
-  int i;
-
-  rm = g_malloc(sizeof(*rm));
-  rm->fd = fd;
-  rm->gdki = gdk_input_add(fd, GDK_INPUT_READ, 
-			   (GdkInputFunction) (match_get_data), rm);
-  rm->pid = pid;
-  rm->mysql_id = mysql_id;
-  rm->nbp = nbp;
-  rm->buf = g_strdup("");
-  rm->players = g_malloc(sizeof(*(rm->players)) * (rm->nbp + 1));
-  for (i = 0; i <= rm->nbp; i++)
-    {
-      rm->players[i].id = (i > 0) ? play_ids[i - 1] : 0;
-      rm->players[i].score = 0;
-      rm->players[i].color = create_player_color(i, rm->nbp + 1);
-    }
-
-  /* Main box */
-  dial = rm->dialog = gtk_dialog_new();
-  gtk_widget_hide(dial);
-  gtk_signal_connect(GTK_OBJECT(dial), "destroy", 
-		     GTK_SIGNAL_FUNC(kill_match_window), rm);
-  gtk_window_set_title(GTK_WINDOW(dial), "Suivi d'un match");
-  gtk_container_set_border_width(GTK_CONTAINER(&(GTK_DIALOG(dial)->window)), 
-				 7);
-  sw = gtk_scrolled_window_new(NULL, NULL);
-  scrw = GTK_SCROLLED_WINDOW(sw);
-  rm->textarea = gtk_text_new(gtk_scrolled_window_get_hadjustment(scrw),
-			      gtk_scrolled_window_get_vadjustment(scrw));
-  gtk_text_set_word_wrap(GTK_TEXT(rm->textarea), FALSE);
-  gtk_text_set_line_wrap(GTK_TEXT(rm->textarea), TRUE);
-  gtk_text_set_editable(GTK_TEXT(rm->textarea), FALSE);
-  gtk_widget_show(sw);
-  gtk_scrolled_window_set_policy(scrw, GTK_POLICY_AUTOMATIC, 
-				 GTK_POLICY_AUTOMATIC);
-  gtk_container_add(GTK_CONTAINER(sw), rm->textarea);
-  gtk_widget_show(rm->textarea);
-
-  /* Buttons */
-  hbox = gtk_hbox_new(FALSE, 3);
-  gtk_widget_show(hbox);
-  widget = gtk_button_new_with_label(" Arrêter ");
-  gtk_widget_show(widget);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(kill_match), rm);
-  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-  widget = gtk_button_new_with_label(" Fermer ");
-  gtk_widget_show(widget);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(kill_match_window), rm);
-  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->action_area), hbox, TRUE,
-		     TRUE, 9);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->vbox), sw, TRUE,
-		     TRUE, 9);
-  
-  gtk_window_set_default_size(GTK_WINDOW(&(GTK_DIALOG(dial)->window)),
-			      340, 280);
-  gtk_widget_show(rm->dialog);
+    rmatch_t *rm;
+    GtkWidget *sw, *dial, *widget, *hbox;
+    GtkScrolledWindow *scrw;
+    int i;
+
+    rm = g_malloc(sizeof(*rm));
+    rm->fd = fd;
+    rm->gdki = gdk_input_add(fd, GDK_INPUT_READ,
+                             ( GdkInputFunction )(match_get_data), rm);
+    rm->pid = pid;
+    rm->mysql_id = mysql_id;
+    rm->nbp = nbp;
+    rm->buf = g_strdup("");
+    rm->players = g_malloc(sizeof(*( rm->players )) * ( rm->nbp + 1 ));
+    for ( i = 0 ; i <= rm->nbp ; i++ )
+    {
+        rm->players[i].id = ( i > 0 ) ? play_ids[i - 1] : 0;
+        rm->players[i].score = 0;
+        rm->players[i].color = create_player_color(i, rm->nbp + 1);
+    }
+
+    /* Main box */
+    dial = rm->dialog = gtk_dialog_new();
+    gtk_widget_hide(dial);
+    gtk_signal_connect(GTK_OBJECT(dial), "destroy",
+                       GTK_SIGNAL_FUNC(kill_match_window), rm);
+    gtk_window_set_title(GTK_WINDOW(dial), "Suivi d'un match");
+    gtk_container_set_border_width(GTK_CONTAINER(&( GTK_DIALOG(dial)->window )),
+                                   7);
+    sw = gtk_scrolled_window_new(NULL, NULL);
+    scrw = GTK_SCROLLED_WINDOW(sw);
+    rm->textarea = gtk_text_new(gtk_scrolled_window_get_hadjustment(scrw),
+                                gtk_scrolled_window_get_vadjustment(scrw));
+    gtk_text_set_word_wrap(GTK_TEXT(rm->textarea), FALSE);
+    gtk_text_set_line_wrap(GTK_TEXT(rm->textarea), TRUE);
+    gtk_text_set_editable(GTK_TEXT(rm->textarea), FALSE);
+    gtk_widget_show(sw);
+    gtk_scrolled_window_set_policy(scrw, GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_container_add(GTK_CONTAINER(sw), rm->textarea);
+    gtk_widget_show(rm->textarea);
+
+    /* Buttons */
+    hbox = gtk_hbox_new(FALSE, 3);
+    gtk_widget_show(hbox);
+    widget = gtk_button_new_with_label(" Arr�ter ");
+    gtk_widget_show(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(kill_match), rm);
+    gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+    widget = gtk_button_new_with_label(" Fermer ");
+    gtk_widget_show(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(kill_match_window), rm);
+    gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->action_area), hbox, TRUE,
+                       TRUE, 9);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->vbox), sw, TRUE,
+                       TRUE, 9);
+
+    gtk_window_set_default_size(GTK_WINDOW(&( GTK_DIALOG(dial)->window )),
+                                340, 280);
+    gtk_widget_show(rm->dialog);
 }
 
-static void do_run_match(const char *cmd, gboolean gfx, int portn, int id,
-			 int nbp, int *play_ids)
+static void do_run_match(const char *cmd, bool gfx, int portn, int id,
+                         int nbp, int *play_ids)
 {
-  char port[11];
-  char buf[MYSQL_BUFFER_SIZE];
-  int fd[2];
-  pid_t pid = -1;
-
-  g_snprintf(port, 11, "%d", portn);
-  pipe(fd);
-  if (!fork())
-    { 
-      close(1);
-      dup2(fd[1], 1);
-      close(fd[0]);
-      if (gl_config->host == NULL)
-	g_snprintf(buf, MYSQL_BUFFER_SIZE, "exec %s -p %s %s", 
-		   gl_config->server, port, cmd);
-      else
-	g_snprintf(buf, MYSQL_BUFFER_SIZE, "exec ssh %s %s -p %s %s", 
-		   gl_config->host, gl_config->server, port, cmd);
-	
-      system(buf);
-      g_snprintf(buf, MYSQL_BUFFER_SIZE, 
-		 "UPDATE Matchs SET statut=0 WHERE id=%d", id);
-      mysql_query(gl_config->mysql, buf);
-      _exit(1);
-    }
-  close(fd[1]);
-  if (gfx)
-    if (!(pid = fork()))
-      {
-	sleep(1);
-	if (gl_config->host == NULL)
-	  execlp(gl_config->gfx_client, gl_config->gfx_client, 
-		 "-d", "-p", port, NULL);
-	else
-	  execlp(gl_config->gfx_client, gl_config->gfx_client, 
-		 "-d", "-p", port, "-h", gl_config->host, NULL);
-	_exit(1);
-      }
-  fcntl(fd[0], F_SETFL, O_NONBLOCK); 
-  create_listener(fd[0], pid, nbp, id, play_ids);
+    char port[11];
+    char buf[MYSQL_BUFFER_SIZE];
+    int fd[2];
+    pid_t pid = -1;
+
+    g_snprintf(port, 11, "%d", portn);
+    pipe(fd);
+    if ( !fork())
+    {
+        close(1);
+        dup2(fd[1], 1);
+        close(fd[0]);
+        if ( gl_config->host == NULL )
+        {
+            g_snprintf(buf, MYSQL_BUFFER_SIZE, "exec %s -p %s %s",
+                       gl_config->server, port, cmd);
+        }
+        else
+        {
+            g_snprintf(buf, MYSQL_BUFFER_SIZE, "exec ssh %s %s -p %s %s",
+                       gl_config->host, gl_config->server, port, cmd);
+        }
+
+        system(buf);
+        g_snprintf(buf, MYSQL_BUFFER_SIZE,
+                   "UPDATE Matchs SET statut=0 WHERE id=%d", id);
+        mysql_query(gl_config->mysql, buf);
+        _exit(1);
+    }
+    close(fd[1]);
+    if ( gfx )
+    {
+        if ( !( pid = fork()))
+        {
+            sleep(1);
+            if ( gl_config->host == NULL )
+            {
+                execlp(gl_config->gfx_client, gl_config->gfx_client,
+                       "-d", "-p", port, NULL);
+            }
+            else
+            {
+                execlp(gl_config->gfx_client, gl_config->gfx_client,
+                       "-d", "-p", port, "-h", gl_config->host, NULL);
+            }
+            _exit(1);
+        }
+    }
+    fcntl(fd[0], F_SETFL, O_NONBLOCK);
+    create_listener(fd[0], pid, nbp, id, play_ids);
 }
 
 static void run_match_commit(GtkWidget *wid, match_t *match)
 {
-  gboolean gfx, pub;
-  int port;
-  char buf[MYSQL_BUFFER_SIZE], buf2[MYSQL_BUFFER_SIZE];
-  char *p = NULL, *s = NULL, *s2 = NULL;
-  int i, j, nbp, play;
-  int nbturn;
-  int players_id[64];
-  int id;
-  
-  if (match == NULL)
-    return;
-  if (match->wids == NULL)
-    return;
-  set_data_from_toggle(match->gfx, &gfx);
-  set_data_from_spin(match->port, &port);
-  set_data_from_spin(match->turns, &nbturn);
-  if (gfx)
-    set_data_from_toggle(match->public, &pub);
-  else 
-    pub = FALSE;
-  p = buf;
-  s = mysql_get_str(gl_config->mysql,
-		    "SELECT fichier FROM Maps WHERE id=%d", match->mapid);
-  if (!g_path_is_absolute(s) && getenv("PROLO_DATA_DIR") != NULL)
-    {
-      s2 = s;
-      s = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S, s2, NULL);
-      g_free(s2);
-    }
-  p += g_snprintf(buf, MYSQL_BUFFER_SIZE, "%s -m %s -n %d ", 
-		  gfx ? "-g" : "", s, nbturn);
-  g_free(s);
-  for (play = i = 0; match->wids[i] != NULL; i++)
-    {
-      s2 = g_strdup(gtk_entry_get_text(GTK_ENTRY(match->wids[i])));
-      if (strcmp(s2, "<Aucun>"))
-	{
-	  players_id[play] = mysql_get_int(gl_config->mysql,
-					   "SELECT id "
-					   "FROM Champions WHERE Nom='%s'", 
-					   s2);
-	  s = mysql_get_str(gl_config->mysql,
-			    "SELECT fichier FROM Champions WHERE id='%d'", 
-			    players_id[play]);
-	  play++;
-	  for (j = 0; s2[j]; j++)
-	    if (!isalnum(s2[j]) && (strchr(ALLOWED_CHARS, s2[j]) == NULL))
-	      s2[j] = '_';
-	  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), "%s:%s ", s2, s);
-	  g_free(s);
-	}
-      g_free(s2);
-    }
-  nbp = play;
-  g_snprintf(buf2, MYSQL_BUFFER_SIZE, 
-	     "INSERT INTO Matchs SET map=%d, host='%s', port=%d, statut=1,"
-             "                       joueurs=%d, auteur=%d, public=%d",
-	     match->mapid, 
-	     (gl_config->host == NULL) ? gl_config->hostname : gl_config->host,
-	     port, nbp, getuid(), pub);
-  mysql_query_gtk(gl_config->mysql, buf2);
-  id = mysql_insert_id(gl_config->mysql);
-  s = gtk_entry_get_text(GTK_ENTRY(match->cmd));
-  p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), "%s ", s);
-  if (!pub)
-    p += g_snprintf(p, MYSQL_BUFFER_SIZE - (p - buf), "-P ");
-  g_free(match->wids);
-  g_free(match);
-  do_run_match(buf, gfx, port, id, nbp, players_id);
+    bool gfx, pub;
+    int port;
+    char buf[MYSQL_BUFFER_SIZE], buf2[MYSQL_BUFFER_SIZE];
+    char *p = NULL, *s = NULL, *s2 = NULL;
+    int i, j, nbp, play;
+    int nbturn;
+    int players_id[64];
+    int id;
+
+    if ( match == NULL )
+    {
+        return;
+    }
+    if ( match->wids == NULL )
+    {
+        return;
+    }
+    set_data_from_toggle(match->gfx, &gfx);
+    set_data_from_spin(match->port, &port);
+    set_data_from_spin(match->turns, &nbturn);
+    if ( gfx )
+    {
+        set_data_from_toggle(match->public, &pub);
+    }
+    else
+    {
+        pub = FALSE;
+    }
+    p = buf;
+    s = mysql_get_str(gl_config->mysql,
+                      "SELECT fichier FROM Maps WHERE id=%d", match->mapid);
+    if ( !g_path_is_absolute(s) && getenv("PROLO_DATA_DIR") != NULL )
+    {
+        s2 = s;
+        s = g_strconcat(getenv("PROLO_DATA_DIR"), G_DIR_SEPARATOR_S, s2, NULL);
+        g_free(s2);
+    }
+    p += g_snprintf(buf, MYSQL_BUFFER_SIZE, "%s -m %s -n %d ",
+                    gfx ? "-g" : "", s, nbturn);
+    g_free(s);
+    for ( play = i = 0 ; match->wids[i] != NULL ; i++ )
+    {
+        s2 = g_strdup(gtk_entry_get_text(GTK_ENTRY(match->wids[i])));
+        if ( strcmp(s2, "<Aucun>"))
+        {
+            players_id[play] = mysql_get_int(gl_config->mysql,
+                                             "SELECT id "
+                                             "FROM Champions WHERE Nom='%s'",
+                                             s2);
+            s = mysql_get_str(gl_config->mysql,
+                              "SELECT fichier FROM Champions WHERE id='%d'",
+                              players_id[play]);
+            play++;
+            for ( j = 0 ; s2[j] ; j++ )
+            {
+                if ( !isalnum(s2[j]) && ( strchr(ALLOWED_CHARS, s2[j]) == NULL ))
+                {
+                    s2[j] = '_';
+                }
+            }
+            p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), "%s:%s ", s2, s);
+            g_free(s);
+        }
+        g_free(s2);
+    }
+    nbp = play;
+    g_snprintf(buf2, MYSQL_BUFFER_SIZE,
+               "INSERT INTO Matchs SET map=%d, host='%s', port=%d, statut=1,"
+               "                       joueurs=%d, auteur=%d, public=%d",
+               match->mapid,
+               ( gl_config->host == NULL ) ? gl_config->hostname : gl_config->host,
+               port, nbp, getuid(), pub);
+    mysql_query_gtk(gl_config->mysql, buf2);
+    id = mysql_insert_id(gl_config->mysql);
+    s = gtk_entry_get_text(GTK_ENTRY(match->cmd));
+    p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), "%s ", s);
+    if ( !pub )
+    {
+        p += g_snprintf(p, MYSQL_BUFFER_SIZE - ( p - buf ), "-P ");
+    }
+    g_free(match->wids);
+    g_free(match);
+    do_run_match(buf, gfx, port, id, nbp, players_id);
 }
 
 GtkWidget *start_match_box()
 {
-  match_t *mat;
-  GtkWidget *dialog = NULL, *tbl = NULL, *wid = NULL;
-  GList *l, *champ = NULL, *maps, *prgs;
-  char buf[MYSQL_BUFFER_SIZE];
-  int nbp, nbc;
-  int i, id;
-
-  maps = GTK_CLIST(gl_config->mapl)->selection;
-  if (maps == NULL)
-    {
-      wid = create_label("Aucune carte sélectionnée.");
-      return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL, 
-			   destroy_widget);
-    }
-
-  prgs = GTK_CLIST(gl_config->prgl)->selection;
-  if (prgs == NULL)
-    {
-      wid = create_label("Aucun champion sélectionné.");
-      return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL, 
-			   destroy_widget);
-    }
-
-  mat = g_malloc(sizeof(*mat));
-  for (l = prgs; l != NULL; l = l->next)
-    {
-      id = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->prgl), 
-					    GPOINTER_TO_INT(l->data)));
-      champ = g_list_append(champ, mysql_get_str(gl_config->mysql,
-						 "SELECT nom FROM Champions "
-						 "WHERE id=%d", id));
-    }
-  champ = g_list_append(champ, g_strdup("<Aucun>"));
-
-  nbc = g_list_length(prgs);
-  mat->mapid = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->mapl), 
-						GPOINTER_TO_INT(maps->data)));
-  nbp = mysql_get_int(gl_config->mysql,
-		      "SELECT joueurs FROM Maps where id=%d", mat->mapid);
-  mat->wids = g_malloc(sizeof(*(mat->wids)) * (nbp + 1));
-
-  tbl = gtk_table_new(4, nbp + 1, FALSE);
-  gtk_widget_show(tbl);
-  dialog = create_dialog("Lancement d'une partie", tbl, " Valider ", 
-			 " Annuler ", run_match_commit, mat, destroy_widget);
-
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label("Graphismes: "),
-			    0, 1, 0, 1);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Port: "),
-			    2, 3, 0, 1);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Tours: "),
-			    0, 1, 1, 2);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Publique: "), 
-			    2, 3, 1, 2);
-  mat->gfx = create_check(TRUE);
-  gtk_tooltips_set_tip(gl_config->tooltips, mat->gfx, 
-		       "Lancer un client graphique", "");
-  mat->port = create_spin(1024, 65535, 4242);
-  gtk_tooltips_set_tip(gl_config->tooltips, mat->port, 
-		       "Port d'écoute du serveur", "");
-  mat->public = create_check(TRUE);
-  gtk_tooltips_set_tip(gl_config->tooltips, mat->public, 
-		       "Autorisé les connexions d'autres clients graphiques ?",
-		       "");
-  mat->turns = create_spin(1, 5000, 200);
-  gtk_tooltips_set_tip(gl_config->tooltips, mat->turns, 
-		       "Nombre de tours que durera la partie", "");
-  gtk_table_attach_defaults(GTK_TABLE(tbl), mat->gfx, 1, 2, 0, 1);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), mat->port, 3, 4, 0, 1);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), mat->turns, 1, 2, 1, 2);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), mat->public, 3, 4, 1, 2);
-
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label("Paramètres: "),
-			    0, 1, 2, 3);
-  mat->cmd = create_entry(NULL, 100);
-  gtk_signal_connect(GTK_OBJECT(mat->cmd), "activate", 
-		     run_match_commit, mat);
-  gtk_signal_connect_after(GTK_OBJECT(mat->cmd), "activate", 
-			   destroy_widget, dialog);
-  gtk_tooltips_set_tip(gl_config->tooltips, mat->cmd, 
-		       "Paramètres supplémentaires à passer au serveur", "");
-  gtk_table_attach_defaults(GTK_TABLE(tbl), mat->cmd, 1, 4, 2, 3);
-  wid = gtk_hseparator_new();
-  gtk_widget_show(wid);
-  gtk_table_attach(GTK_TABLE(tbl), wid, 0, 4, 3, 4, GTK_FILL, GTK_FILL, 2, 5);
-
-  for (i = 0, l = champ; i < nbp; i++)
-    {
-      snprintf(buf, MYSQL_BUFFER_SIZE, "Joueur n°%d: ", i);
-      gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(buf),
-				0, 1, i + 4, i + 5);
-      wid = gtk_combo_new();
-      gtk_widget_show(wid);
-      gtk_tooltips_set_tip(gl_config->tooltips, GTK_COMBO(wid)->entry, 
-			   "Choix des champions à utiliser", "");
-      gtk_combo_set_popdown_strings(GTK_COMBO(wid), champ);
-      gtk_combo_set_value_in_list(GTK_COMBO(wid), TRUE, TRUE);
-      gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid)->entry), l->data);
-      gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid)->entry), FALSE);
-      gtk_table_attach_defaults(GTK_TABLE(tbl), wid, 1, 4, i + 4, i + 5);
-      mat->wids[i] = GTK_COMBO(wid)->entry;
-      if (l->next != NULL)
-	l = l->next;
-    }
-  mat->wids[nbp] = NULL;
-
-  for (l = champ; l != NULL; l = l->next)
-    g_free(l->data);
-  g_list_free(champ);
-
-  return dialog;
+    match_t *mat;
+    GtkWidget *dialog = NULL, *tbl = NULL, *wid = NULL;
+    GList *l, *champ = NULL, *maps, *prgs;
+    char buf[MYSQL_BUFFER_SIZE];
+    int nbp, nbc;
+    int i, id;
+
+    maps = GTK_CLIST(gl_config->mapl)->selection;
+    if ( maps == NULL )
+    {
+        wid = create_label("Aucune carte s�lectionn�e.");
+        return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL,
+                             destroy_widget);
+    }
+
+    prgs = GTK_CLIST(gl_config->prgl)->selection;
+    if ( prgs == NULL )
+    {
+        wid = create_label("Aucun champion s�lectionn�.");
+        return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL,
+                             destroy_widget);
+    }
+
+    mat = g_malloc(sizeof(*mat));
+    for ( l = prgs ; l != NULL ; l = l->next )
+    {
+        id = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->prgl),
+                                              GPOINTER_TO_INT(l->data)));
+        champ = g_list_append(champ, mysql_get_str(gl_config->mysql,
+                                                   "SELECT nom FROM Champions "
+                                                   "WHERE id=%d", id));
+    }
+    champ = g_list_append(champ, g_strdup("<Aucun>"));
+
+    nbc = g_list_length(prgs);
+    mat->mapid = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->mapl),
+                                                  GPOINTER_TO_INT(maps->data)));
+    nbp = mysql_get_int(gl_config->mysql,
+                        "SELECT joueurs FROM Maps where id=%d", mat->mapid);
+    mat->wids = g_malloc(sizeof(*( mat->wids )) * ( nbp + 1 ));
+
+    tbl = gtk_table_new(4, nbp + 1, FALSE);
+    gtk_widget_show(tbl);
+    dialog = create_dialog("Lancement d'une partie", tbl, " Valider ",
+                           " Annuler ", run_match_commit, mat, destroy_widget);
+
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label("Graphismes: "),
+                              0, 1, 0, 1);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Port: "),
+                              2, 3, 0, 1);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Tours: "),
+                              0, 1, 1, 2);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Publique: "),
+                              2, 3, 1, 2);
+    mat->gfx = create_check(TRUE);
+    gtk_tooltips_set_tip(gl_config->tooltips, mat->gfx,
+                         "Lancer un client graphique", "");
+    mat->port = create_spin(1024, 65535, 4242);
+    gtk_tooltips_set_tip(gl_config->tooltips, mat->port,
+                         "Port d'�coute du serveur", "");
+    mat->public = create_check(TRUE);
+    gtk_tooltips_set_tip(gl_config->tooltips, mat->public,
+                         "Autoris� les connexions d'autres clients graphiques ?",
+                         "");
+    mat->turns = create_spin(1, 5000, 200);
+    gtk_tooltips_set_tip(gl_config->tooltips, mat->turns,
+                         "Nombre de tours que durera la partie", "");
+    gtk_table_attach_defaults(GTK_TABLE(tbl), mat->gfx, 1, 2, 0, 1);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), mat->port, 3, 4, 0, 1);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), mat->turns, 1, 2, 1, 2);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), mat->public, 3, 4, 1, 2);
+
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label("Param�tres: "),
+                              0, 1, 2, 3);
+    mat->cmd = create_entry(NULL, 100);
+    gtk_signal_connect(GTK_OBJECT(mat->cmd), "activate",
+                       run_match_commit, mat);
+    gtk_signal_connect_after(GTK_OBJECT(mat->cmd), "activate",
+                             destroy_widget, dialog);
+    gtk_tooltips_set_tip(gl_config->tooltips, mat->cmd,
+                         "Param�tres suppl�mentaires � passer au serveur", "");
+    gtk_table_attach_defaults(GTK_TABLE(tbl), mat->cmd, 1, 4, 2, 3);
+    wid = gtk_hseparator_new();
+    gtk_widget_show(wid);
+    gtk_table_attach(GTK_TABLE(tbl), wid, 0, 4, 3, 4, GTK_FILL, GTK_FILL, 2, 5);
+
+    for ( i = 0, l = champ ; i < nbp ; i++ )
+    {
+        snprintf(buf, MYSQL_BUFFER_SIZE, "Joueur n�%d: ", i);
+        gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(buf),
+                                  0, 1, i + 4, i + 5);
+        wid = gtk_combo_new();
+        gtk_widget_show(wid);
+        gtk_tooltips_set_tip(gl_config->tooltips, GTK_COMBO(wid)->entry,
+                             "Choix des champions � utiliser", "");
+        gtk_combo_set_popdown_strings(GTK_COMBO(wid), champ);
+        gtk_combo_set_value_in_list(GTK_COMBO(wid), TRUE, TRUE);
+        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid)->entry), l->data);
+        gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid)->entry), FALSE);
+        gtk_table_attach_defaults(GTK_TABLE(tbl), wid, 1, 4, i + 4, i + 5);
+        mat->wids[i] = GTK_COMBO(wid)->entry;
+        if ( l->next != NULL )
+        {
+            l = l->next;
+        }
+    }
+    mat->wids[nbp] = NULL;
+
+    for ( l = champ ; l != NULL ; l = l->next )
+    {
+        g_free(l->data);
+    }
+    g_list_free(champ);
+
+    return dialog;
 }
 

+ 331 - 282
meta-client/run_tournois.c

@@ -1,10 +1,8 @@
-/* $Id: run_tournois.c,v 1.6 2001/05/07 02:41:36 kilobug Exp $ */
-
 #include "mclient.h"
 #include "tournois.h"
 #include <signal.h>
 
-#define ALLOWED_CHARS "_+-$&*!@#~.éáàèëïûôêîìä"
+#define ALLOWED_CHARS "_+-$&*!@#~.������������"
 
 static rt_t *gl_rt;
 
@@ -12,90 +10,100 @@ static void trn_start_new_match(rt_t *rt);
 
 static void trn_display_line(rt_t *rt, const char *buf)
 {
-  GtkAdjustment *adj;
-  int l;
+    GtkAdjustment *adj;
+    int l;
 
-  if (rt->textarea == NULL)
-    return;
-  gtk_text_freeze(GTK_TEXT(rt->textarea));
+    if ( rt->textarea == NULL )
+    {
+        return;
+    }
+    gtk_text_freeze(GTK_TEXT(rt->textarea));
 
-  l = gtk_text_get_length(GTK_TEXT(rt->textarea));
-  l -= 5000;
-  if (l > 0)
+    l = gtk_text_get_length(GTK_TEXT(rt->textarea));
+    l -= 5000;
+    if ( l > 0 )
     {
-      while ((GTK_TEXT_INDEX(GTK_TEXT(rt->textarea), l) != '\n') && l > 0)
-	l--;
-      if (l > 0)
-	{
-	  gtk_text_set_point(GTK_TEXT(rt->textarea), 0);
-	  gtk_text_forward_delete(GTK_TEXT(rt->textarea), l);
-	  gtk_text_set_point(GTK_TEXT(rt->textarea), 
-			     gtk_text_get_length(GTK_TEXT(rt->textarea)));
-	}
+        while (( GTK_TEXT_INDEX(GTK_TEXT(rt->textarea), l) != '\n' ) && l > 0 )
+        {
+            l--;
+        }
+        if ( l > 0 )
+        {
+            gtk_text_set_point(GTK_TEXT(rt->textarea), 0);
+            gtk_text_forward_delete(GTK_TEXT(rt->textarea), l);
+            gtk_text_set_point(GTK_TEXT(rt->textarea),
+                               gtk_text_get_length(GTK_TEXT(rt->textarea)));
+        }
     }
 
-  gtk_text_insert(GTK_TEXT(rt->textarea), NULL, 
-		  NULL, NULL, buf, -1);
-  gtk_text_thaw(GTK_TEXT(rt->textarea));  
-  adj = GTK_TEXT(rt->textarea)->vadj;
-  gtk_adjustment_set_value(adj, adj->upper);
+    gtk_text_insert(GTK_TEXT(rt->textarea), NULL,
+                    NULL, NULL, buf, -1);
+    gtk_text_thaw(GTK_TEXT(rt->textarea));
+    adj = GTK_TEXT(rt->textarea)->vadj;
+    gtk_adjustment_set_value(adj, adj->upper);
 }
 
 static void trn_end(rt_t *rt)
 {
-  int r, i, j, class, class2;
-  char buf[MYSQL_BUFFER_SIZE];
-  char *s;
+    int r, i, j, class, class2;
+    char buf[MYSQL_BUFFER_SIZE];
+    char *s;
+
+    alarm(0);
+    if ( rt->gdki > 0 )
+    {
+        gdk_input_remove(rt->gdki);
+        close(rt->fd);
+    }
+    rt->gdki = -1;
 
-  alarm(0);
-  if (rt->gdki > 0)
+    if ( !rt->timeout )
     {
-      gdk_input_remove(rt->gdki);
-      close(rt->fd);      
+        for ( i = 0 ; i < rt->nbp ; i++ )
+        {
+            if ( rt->scores[i] != 0 )
+            {
+                class2 = class = 1;
+                for ( j = 0 ; j < rt->nbp ; j++ )
+                {
+                    if ( rt->scores[j] > rt->scores[i] )
+                    {
+                        class *= 2;
+                        class2++;
+                    }
+                }
+                r = rt->nbp * 100 / class;
+                mysql_do_query(gl_config->mysql,
+                               "UPDATE Champions "
+                               "SET nbmap=nbmap+1, total=total+%d "
+                               "WHERE id=%d",
+                               r, rt->champ[rt->chmp[i]]);
+                mysql_do_query(gl_config->mysql,
+                               "UPDATE Champions "
+                               "SET score=total/nbmap, best=GREATEST(best, %f) "
+                               "WHERE id=%d", rt->scores[i],
+                               rt->champ[rt->chmp[i]]);
+
+                s = mysql_get_str(gl_config->mysql,
+                                  "SELECT login FROM Bitmaps B, Champions C "
+                                  "WHERE B.id = C.auteur AND C.id=%d",
+                                  rt->champ[rt->chmp[i]]);
+                g_snprintf(buf, MYSQL_BUFFER_SIZE, "Joueur %s: %f (%d) => %d.\n",
+                           s, rt->scores[i], class2, r);
+                trn_display_line(rt, buf);
+                g_free(s);
+            }
+        }
     }
-  rt->gdki = -1;
-
-  if (!rt->timeout)
-    for (i = 0; i < rt->nbp; i++)
-      if (rt->scores[i] != 0)
-	{
-	  class2 = class = 1;
-	  for (j = 0; j < rt->nbp; j++)
-	    if (rt->scores[j] > rt->scores[i])
-	      {
-		class *= 2;
-		class2++;
-	      }
-	  r = rt->nbp * 100 / class;
-	  mysql_do_query(gl_config->mysql, 
-			 "UPDATE Champions "
-			 "SET nbmap=nbmap+1, total=total+%d "
-			 "WHERE id=%d",
-			 r, rt->champ[rt->chmp[i]]);
-	  mysql_do_query(gl_config->mysql,
-			 "UPDATE Champions "
-			 "SET score=total/nbmap, best=GREATEST(best, %f) "
-			 "WHERE id=%d", rt->scores[i], 		     
-			 rt->champ[rt->chmp[i]]);
-	  
-	  s = mysql_get_str(gl_config->mysql,
-			    "SELECT login FROM Bitmaps B, Champions C "
-			    "WHERE B.id = C.auteur AND C.id=%d", 
-			    rt->champ[rt->chmp[i]]);
-	  g_snprintf(buf, MYSQL_BUFFER_SIZE, "Joueur %s: %f (%d) => %d.\n",
-		     s, rt->scores[i], class2, r);
-	  trn_display_line(rt, buf);
-	  g_free(s);
-	}
-  trn_start_new_match(rt);
+    trn_start_new_match(rt);
 }
 
 static void sigalarm(int foo)
-{  
-  gl_rt->timeout = TRUE;
-  system("killall server");
-  fprintf(stderr, "!!!!!!! Timeout.\n");
-  trn_end(gl_rt);
+{
+    gl_rt->timeout = TRUE;
+    system("killall server");
+    fprintf(stderr, "!!!!!!! Timeout.\n");
+    trn_end(gl_rt);
 }
 
 static void nothing(int foo)
@@ -104,290 +112,331 @@ static void nothing(int foo)
 
 static void trn_check_score(rt_t *rt, const char *buf)
 {
-  int i;
-  float f;
-  char *s;
-
-  if (strncmp(buf, "<server> Player ", 16))
-    return;
-  i = strtol(buf + 16, &s, 10);
-  s += 3;
-  f = atof(s);
-  mysql_do_query(gl_config->mysql, 
-		 "INSERT INTO Scores SET champion=%d, score='%f', match_id=%d",
-		 rt->champ[rt->chmp[i - 1]], f, rt->mysql_id);
-  rt->scores[i - 1] = f;
+    int i;
+    float f;
+    char *s;
+
+    if ( strncmp(buf, "<server> Player ", 16))
+    {
+        return;
+    }
+    i = strtol(buf + 16, &s, 10);
+    s += 3;
+    f = atof(s);
+    mysql_do_query(gl_config->mysql,
+                   "INSERT INTO Scores SET champion=%d, score='%f', match_id=%d",
+                   rt->champ[rt->chmp[i - 1]], f, rt->mysql_id);
+    rt->scores[i - 1] = f;
 }
 
-static gboolean trn_treat_line(rt_t *rt, const char *buf)
+static bool trn_treat_line(rt_t *rt, const char *buf)
 {
-  alarm(10);
-  if (!strcmp(buf, "Bye!\n"))
+    alarm(10);
+    if ( !strcmp(buf, "Bye!\n"))
     {
-      trn_display_line(rt, "\nMatch terminé.\n");
-      trn_end(rt);
-      return FALSE;
+        trn_display_line(rt, "\nMatch termin�.\n");
+        trn_end(rt);
+        return FALSE;
     }
-  if (strncmp(buf, "<server>", 8))
-    trn_display_line(rt, buf);
-  else
-    trn_check_score(rt, buf);
-  return TRUE;
+    if ( strncmp(buf, "<server>", 8))
+    {
+        trn_display_line(rt, buf);
+    }
+    else
+    {
+        trn_check_score(rt, buf);
+    }
+    return TRUE;
 }
 
 static void trn_get_data(rt_t *rt, int fd, GdkInputCondition foo)
 {
-  char buf[MYSQL_BUFFER_SIZE], *s, *p;
-  int sz;
-  gboolean r;
-
-  if (rt == NULL)
-    return;
-  sz = read(fd, buf, MYSQL_BUFFER_SIZE - 1);
-  if (sz == -1)
+    char buf[MYSQL_BUFFER_SIZE], *s, *p;
+    int sz;
+    bool r;
+
+    if ( rt == NULL )
     {
-      trn_end(rt);
-      return;
+        return;
     }
-  buf[sz] = 0;
-  s = g_strconcat(rt->buf, buf, NULL);
-  g_free(rt->buf);
-  rt->buf = s;
+    sz = read(fd, buf, MYSQL_BUFFER_SIZE - 1);
+    if ( sz == -1 )
+    {
+        trn_end(rt);
+        return;
+    }
+    buf[sz] = 0;
+    s = g_strconcat(rt->buf, buf, NULL);
+    g_free(rt->buf);
+    rt->buf = s;
 
-  while ((p = strchr(rt->buf, '\n')) != NULL)
+    while (( p = strchr(rt->buf, '\n')) != NULL )
     {
-      s = rt->buf;
-      rt->buf = g_strdup(p + 1);
-      p[1] = 0;
-      r = trn_treat_line(rt, s);
-      g_free(s);
-      if (!r)
-	break;
-    }   
+        s = rt->buf;
+        rt->buf = g_strdup(p + 1);
+        p[1] = 0;
+        r = trn_treat_line(rt, s);
+        g_free(s);
+        if ( !r )
+        {
+            break;
+        }
+    }
 }
 
 static void trn_do_start_match(rt_t *rt)
 {
-  int i, j;
-  char buf[11];
-  char buf2[MYSQL_BUFFER_SIZE];
-  int fd[2];
-  char *s, *n, *f;
-
-  fprintf(stderr, "\nStarting match %d of %d between: ", rt->cur, rt->nbm);
-  for (i = 0; i < rt->nbp; i++)
+    int i, j;
+    char buf[11];
+    char buf2[MYSQL_BUFFER_SIZE];
+    int fd[2];
+    char *s, *n, *f;
+
+    fprintf(stderr, "\nStarting match %d of %d between: ", rt->cur, rt->nbm);
+    for ( i = 0 ; i < rt->nbp ; i++ )
     {
-      fprintf(stderr, "%d ", rt->chmp[i]);
+        fprintf(stderr, "%d ", rt->chmp[i]);
     }
-  fprintf(stderr, "\n");
-  g_snprintf(buf2, MYSQL_BUFFER_SIZE, 
-	     "INSERT INTO Matchs SET map=%d, host='%s', port=%d, statut=1,"
-             "                       joueurs=%d, auteur=%d, public=%d",
-	     rt->mapid,
- 	     (gl_config->host == NULL) ? gl_config->hostname : gl_config->host,
-	     4242, rt->nbp, getuid(), FALSE);
-  mysql_query_gtk(gl_config->mysql, buf2);
-  rt->mysql_id = mysql_insert_id(gl_config->mysql);
-  pipe(fd);
-  if (!fork())
-    { 
-      g_snprintf(buf, 11, "%d", rt->nbt);
-      close(1);
-      dup2(fd[1], 1);
-      close(fd[0]);
-      /* Memory leak mais suivi d'un execlp */
-      s = g_strconcat(gl_config->server, " -n ", buf, " -m ", rt->map, " -q ", 
-		      rt->cmd, " ", NULL);
-      for (i = 0; i < rt->nbp; i++)
-	{
-	  n = mysql_get_str(gl_config->mysql,
-			    "SELECT nom FROM Champions "
-			    "WHERE id=%d",
-			    rt->champ[rt->chmp[i]]);
-	  for (j = 0; n[j]; j++)
-	    if (!isalnum(n[j]) && (strchr(ALLOWED_CHARS, n[j]) == NULL))
-	      n[j] = '_';
-	  f = mysql_get_str(gl_config->mysql,
-			    "SELECT fichier FROM Champions "
-			    "WHERE id=%d",
-			    rt->champ[rt->chmp[i]]);
-	  if ((n != NULL) && (f != NULL))
-	    s = g_strconcat(s, " ", n, ":", f, NULL);
-	  g_free(n);
-	  g_free(f);
-	}
-      sleep(1);
-      if (gl_config->host == NULL)
-	execlp("sh", "sh", "-c", s, NULL);
-      else
-	execlp("ssh", "ssh", gl_config->host, s, NULL);
-      _exit(1);
+    fprintf(stderr, "\n");
+    g_snprintf(buf2, MYSQL_BUFFER_SIZE,
+               "INSERT INTO Matchs SET map=%d, host='%s', port=%d, statut=1,"
+               "                       joueurs=%d, auteur=%d, public=%d",
+               rt->mapid,
+               ( gl_config->host == NULL ) ? gl_config->hostname : gl_config->host,
+               4242, rt->nbp, getuid(), FALSE);
+    mysql_query_gtk(gl_config->mysql, buf2);
+    rt->mysql_id = mysql_insert_id(gl_config->mysql);
+    pipe(fd);
+    if ( !fork())
+    {
+        g_snprintf(buf, 11, "%d", rt->nbt);
+        close(1);
+        dup2(fd[1], 1);
+        close(fd[0]);
+        /* Memory leak mais suivi d'un execlp */
+        s = g_strconcat(gl_config->server, " -n ", buf, " -m ", rt->map, " -q ",
+                        rt->cmd, " ", NULL);
+        for ( i = 0 ; i < rt->nbp ; i++ )
+        {
+            n = mysql_get_str(gl_config->mysql,
+                              "SELECT nom FROM Champions "
+                              "WHERE id=%d",
+                              rt->champ[rt->chmp[i]]);
+            for ( j = 0 ; n[j] ; j++ )
+            {
+                if ( !isalnum(n[j]) && ( strchr(ALLOWED_CHARS, n[j]) == NULL ))
+                {
+                    n[j] = '_';
+                }
+            }
+            f = mysql_get_str(gl_config->mysql,
+                              "SELECT fichier FROM Champions "
+                              "WHERE id=%d",
+                              rt->champ[rt->chmp[i]]);
+            if (( n != NULL ) && ( f != NULL ))
+            {
+                s = g_strconcat(s, " ", n, ":", f, NULL);
+            }
+            g_free(n);
+            g_free(f);
+        }
+        sleep(1);
+        if ( gl_config->host == NULL )
+        {
+            execlp("sh", "sh", "-c", s, NULL);
+        }
+        else
+        {
+            execlp("ssh", "ssh", gl_config->host, s, NULL);
+        }
+        _exit(1);
+    }
+    close(fd[1]);
+    fcntl(fd[0], F_SETFL, O_NONBLOCK);
+    for ( i = 0 ; i < rt->nbp ; i++ )
+    {
+        rt->scores[i] = 0;
     }
-  close(fd[1]);
-  fcntl(fd[0], F_SETFL, O_NONBLOCK);
-  for (i = 0; i < rt->nbp; i++)
-    rt->scores[i] = 0;
-  rt->fd = fd[0];
-  rt->gdki = gdk_input_add(fd[0], GDK_INPUT_READ, 
-			   (GdkInputFunction) (trn_get_data), rt);
-  alarm(20);
+    rt->fd = fd[0];
+    rt->gdki = gdk_input_add(fd[0], GDK_INPUT_READ,
+                             ( GdkInputFunction )(trn_get_data), rt);
+    alarm(20);
 }
 
 typedef struct _trn_comb_t
 {
-  int *max_allowed;
-  int *cnt;
+    int *max_allowed;
+    int *cnt;
 } trn_comb_t;
 
 typedef struct _trn_rand_t
 {
-  int *cnt;
+    int *cnt;
 } trn_rand_t;
 
 static void trn_make_rand(rt_t *rt)
 {
-  int i;
-  int max;
-  trn_rand_t *randd;
+    int i;
+    int max;
+    trn_rand_t *randd;
 
-  randd = rt->data;
-  max = rt->nbm * rt->nbp / rt->nbc + 1;
-  for (i = 0; i < rt->nbp; i++)
+    randd = rt->data;
+    max = rt->nbm * rt->nbp / rt->nbc + 1;
+    for ( i = 0 ; i < rt->nbp ; i++ )
     {
-      do 
-	rt->chmp[i] = random() % rt->nbc;	  
-      while (randd->cnt[rt->chmp[i]] >= max);
-      randd->cnt[rt->chmp[i]]++;
+        do
+        {
+            rt->chmp[i] = random() % rt->nbc;
+        } while ( randd->cnt[rt->chmp[i]] >= max );
+        randd->cnt[rt->chmp[i]]++;
     }
 }
 
 static void trn_make_comb(rt_t *rt)
 {
-  trn_comb_t *comb;
-  int j, i;
-  
-  comb = rt->data;
-  for (i = 0; i < rt->nbp; i++)
-    rt->chmp[i] = comb->cnt[i];
-
-  for (j = rt->nbp - 1; j > 0; j--)
-    if (comb->cnt[j] < comb->max_allowed[j])
-      break;
-  comb->cnt[j]++;
-  if (comb->cnt[j] > comb->max_allowed[j])
-    for (i = 0; i < rt->nbp; i++)
-      comb->cnt[i] = i;
-  else
-    for (j++; j < rt->nbp - 1; j++)
-      comb->cnt[j] = comb->cnt[j - 1] + 1;
+    trn_comb_t *comb;
+    int j, i;
+
+    comb = rt->data;
+    for ( i = 0 ; i < rt->nbp ; i++ )
+    {
+        rt->chmp[i] = comb->cnt[i];
+    }
+
+    for ( j = rt->nbp - 1 ; j > 0 ; j-- )
+    {
+        if ( comb->cnt[j] < comb->max_allowed[j] )
+        {
+            break;
+        }
+    }
+    comb->cnt[j]++;
+    if ( comb->cnt[j] > comb->max_allowed[j] )
+    {
+        for ( i = 0 ; i < rt->nbp ; i++ )
+        {
+            comb->cnt[i] = i;
+        }
+    }
+    else
+    {
+        for ( j++ ; j < rt->nbp - 1 ; j++ )
+        {
+            comb->cnt[j] = comb->cnt[j - 1] + 1;
+        }
+    }
 }
 
 static void trn_start_new_match(rt_t *rt)
 {
-  if (rt->cur >= rt->nbm)
+    if ( rt->cur >= rt->nbm )
     {
-      trn_display_line(rt, "\nTournois terminé.\n");
-      rt->run = FALSE;
-      trn_free(rt);      
-      return;
+        trn_display_line(rt, "\nTournois termin�.\n");
+        rt->run = FALSE;
+        trn_free(rt);
+        return;
     }
-  rt->timeout = FALSE;
-  gl_rt = rt;
-  rt->cur++;
-  switch (rt->methode)
+    rt->timeout = FALSE;
+    gl_rt = rt;
+    rt->cur++;
+    switch ( rt->methode )
     {
     case met_rand:
-      trn_make_rand(rt);
-      break;
+        trn_make_rand(rt);
+        break;
     case met_comb:
-      trn_make_comb(rt);
-      break;
+        trn_make_comb(rt);
+        break;
     case met_pyr:
-      trn_make_rand(rt);
-      break;
+        trn_make_rand(rt);
+        break;
     case met_rot:
-      trn_make_rand(rt);
-      break;
+        trn_make_rand(rt);
+        break;
     default:
-      fprintf(stderr, "Internal error in trn_init. Aborting.\n");
-      exit(1);
-      break;
-    }  
-  trn_do_start_match(rt);
+        fprintf(stderr, "Internal error in trn_init. Aborting.\n");
+        exit(1);
+        break;
+    }
+    trn_do_start_match(rt);
 }
 
 void trn_init(rt_t *rt)
 {
-  int i;
-  trn_comb_t *comb;
-  trn_rand_t *rand;
+    int i;
+    trn_comb_t *comb;
+    trn_rand_t *rand;
 
-  switch (rt->methode)
+    switch ( rt->methode )
     {
     case met_rand:
-      rt->data = rand = g_malloc(sizeof(*rand));
-      rand->cnt = g_malloc(sizeof(int) * rt->nbc);
-      bzero(rand->cnt, sizeof(int) * rt->nbc);
-      break;
+        rt->data = rand = g_malloc(sizeof(*rand));
+        rand->cnt = g_malloc(sizeof(int) * rt->nbc);
+        bzero(rand->cnt, sizeof(int) * rt->nbc);
+        break;
     case met_pyr:
     case met_rot:
-      rt->data = NULL;
-      break;
+        rt->data = NULL;
+        break;
     case met_comb:
-      rt->data = comb = g_malloc(sizeof(*comb));
-      comb->cnt = g_malloc(sizeof(int) * rt->nbp);
-      comb->max_allowed = g_malloc(sizeof(int) * rt->nbp);
-      for (i = 0; i < rt->nbp; i++)
-	{
-	  comb->cnt[i] = i;
-	  comb->max_allowed[i] = rt->nbc - (rt->nbp - i);
-	}
-      break;
+        rt->data = comb = g_malloc(sizeof(*comb));
+        comb->cnt = g_malloc(sizeof(int) * rt->nbp);
+        comb->max_allowed = g_malloc(sizeof(int) * rt->nbp);
+        for ( i = 0 ; i < rt->nbp ; i++ )
+        {
+            comb->cnt[i] = i;
+            comb->max_allowed[i] = rt->nbc - ( rt->nbp - i );
+        }
+        break;
     default:
-      fprintf(stderr, "Internal error in trn_init. Aborting.\n");
-      exit(1);
-      break;
+        fprintf(stderr, "Internal error in trn_init. Aborting.\n");
+        exit(1);
+        break;
     }
-  rt->gdki = -1;
-  gl_rt = rt;
-  signal(SIGALRM, sigalarm);
-  trn_start_new_match(rt);
+    rt->gdki = -1;
+    gl_rt = rt;
+    signal(SIGALRM, sigalarm);
+    trn_start_new_match(rt);
 }
 
 void trn_free(rt_t *rt)
 {
-  trn_comb_t *comb;
-  trn_rand_t *rand;
+    trn_comb_t *comb;
+    trn_rand_t *rand;
 
-  if (rt->run || rt->disp)
-    return;
-  switch (rt->methode)
+    if ( rt->run || rt->disp )
+    {
+        return;
+    }
+    switch ( rt->methode )
     {
     case met_rand:
-      rand = rt->data;
-      g_free(rand->cnt);
-      g_free(rand);
-      break;
+        rand = rt->data;
+        g_free(rand->cnt);
+        g_free(rand);
+        break;
     case met_pyr:
     case met_rot:
-      break;
+        break;
     case met_comb:
-      comb = rt->data;
-      g_free(comb->cnt);
-      g_free(comb->max_allowed);
-      g_free(comb);
-      break;
+        comb = rt->data;
+        g_free(comb->cnt);
+        g_free(comb->max_allowed);
+        g_free(comb);
+        break;
     default:
-      fprintf(stderr, "Internal error in trn_init. Aborting.\n");
-      exit(1);
-      break;
+        fprintf(stderr, "Internal error in trn_init. Aborting.\n");
+        exit(1);
+        break;
     }
-  g_free(rt->cmd);
-  g_free(rt->chmp);
-  g_free(rt->map);
-  if (rt->buf != NULL)
-    g_free(rt->buf);
-  g_free(rt->scores);
-  g_free(rt);
+    g_free(rt->cmd);
+    g_free(rt->chmp);
+    g_free(rt->map);
+    if ( rt->buf != NULL )
+    {
+        g_free(rt->buf);
+    }
+    g_free(rt->scores);
+    g_free(rt);
 }
 

+ 191 - 181
meta-client/tournois.c

@@ -1,216 +1,226 @@
-/* $Id: tournois.c,v 1.4 2001/05/07 02:41:36 kilobug Exp $ */
-
 #include "mclient.h"
 #include "tournois.h"
 
 typedef struct _tournois_t
 {
-  int mapid, nbc;
-  GtkWidget *nbp, *nbt, *nbm, *methode, *cmd;
-  int *champ;
+    int mapid, nbc;
+    GtkWidget *nbp, *nbt, *nbm, *methode, *cmd;
+    int *champ;
 } tournois_t;
 
 static void kill_trn_window(GtkWidget *wid, rt_t *rt)
 {
-  if (rt->dialog == NULL)
-    return;
-  gtk_widget_destroy(rt->dialog);
-  rt->dialog = NULL;
-  rt->textarea = NULL;  
-  rt->disp = FALSE;
+    if ( rt->dialog == NULL )
+    {
+        return;
+    }
+    gtk_widget_destroy(rt->dialog);
+    rt->dialog = NULL;
+    rt->textarea = NULL;
+    rt->disp = FALSE;
 }
 
 static void kill_trn(GtkWidget *wid, rt_t *rt)
 {
-  rt->nbm = 0;
+    rt->nbm = 0;
 }
 
-static char *trn_met[] = { "Combinatoire", "Aléatoire", NULL, "Rotatif",
-			   "Pyramidal", NULL };
+static char *trn_met[] = { "Combinatoire", "Al�atoire", NULL, "Rotatif",
+                           "Pyramidal", NULL };
 
 static void run_trn_commit(GtkWidget *wid, tournois_t *trn)
 {
-  rt_t *rt;
-  char *s;
-  int i;
-  GtkWidget *sw, *dial, *widget, *hbox;
-  GtkScrolledWindow *scrw;
-
-  rt = g_malloc(sizeof(*rt));
-  rt->mapid = trn->mapid;
-  rt->nbc = trn->nbc;
-  rt->champ = trn->champ;
-  rt->cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(trn->cmd)));
-  set_data_from_spin(trn->nbp, &rt->nbp);
-  set_data_from_spin(trn->nbt, &rt->nbt);
-  set_data_from_spin(trn->nbm, &rt->nbm);
-  s = gtk_entry_get_text(GTK_ENTRY(trn->methode));
-  for (i = 0; trn_met[i] != NULL; i++)
-    if (!strcmp(trn_met[i], s))
-      break;
-  rt->scores = g_malloc(sizeof(*rt->scores) * rt->nbp);
-  rt->methode = i;
-  rt->disp = rt->run = TRUE;
-  rt->cur = 0;
-  rt->buf = g_strdup("");
-  rt->chmp = g_malloc(sizeof(int) * rt->nbp);
-  s = mysql_get_str(gl_config->mysql,
-		    "SELECT fichier FROM Maps "
-		    "WHERE id=%d", rt->mapid);
-  if (!g_path_is_absolute(s))
+    rt_t *rt;
+    char *s;
+    int i;
+    GtkWidget *sw, *dial, *widget, *hbox;
+    GtkScrolledWindow *scrw;
+
+    rt = g_malloc(sizeof(*rt));
+    rt->mapid = trn->mapid;
+    rt->nbc = trn->nbc;
+    rt->champ = trn->champ;
+    rt->cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(trn->cmd)));
+    set_data_from_spin(trn->nbp, &rt->nbp);
+    set_data_from_spin(trn->nbt, &rt->nbt);
+    set_data_from_spin(trn->nbm, &rt->nbm);
+    s = gtk_entry_get_text(GTK_ENTRY(trn->methode));
+    for ( i = 0 ; trn_met[i] != NULL ; i++ )
+    {
+        if ( !strcmp(trn_met[i], s))
+        {
+            break;
+        }
+    }
+    rt->scores = g_malloc(sizeof(*rt->scores) * rt->nbp);
+    rt->methode = i;
+    rt->disp = rt->run = TRUE;
+    rt->cur = 0;
+    rt->buf = g_strdup("");
+    rt->chmp = g_malloc(sizeof(int) * rt->nbp);
+    s = mysql_get_str(gl_config->mysql,
+                      "SELECT fichier FROM Maps "
+                      "WHERE id=%d", rt->mapid);
+    if ( !g_path_is_absolute(s))
+    {
+        rt->map = g_strconcat(getenv("PROLO_DATA_DIR"),
+                              G_DIR_SEPARATOR_S, s, NULL);
+        g_free(s);
+    }
+    else
     {
-      rt->map = g_strconcat(getenv("PROLO_DATA_DIR"), 
-			    G_DIR_SEPARATOR_S, s, NULL);
-      g_free(s);
+        rt->map = s;
     }
-  else
-    rt->map = s;
-
-  trn_init(rt);
-
-  /* Main box */
-  dial = rt->dialog = gtk_dialog_new();
-  gtk_widget_hide(dial);
-  gtk_signal_connect(GTK_OBJECT(dial), "destroy", 
-		     GTK_SIGNAL_FUNC(kill_trn_window), rt);
-  gtk_window_set_title(GTK_WINDOW(dial), "Suivi d'un tournois");
-  gtk_container_set_border_width(GTK_CONTAINER(&(GTK_DIALOG(dial)->window)), 
-				 7);
-  sw = gtk_scrolled_window_new(NULL, NULL);
-  scrw = GTK_SCROLLED_WINDOW(sw);
-  rt->textarea = gtk_text_new(gtk_scrolled_window_get_hadjustment(scrw),
-			      gtk_scrolled_window_get_vadjustment(scrw));
-  gtk_text_set_word_wrap(GTK_TEXT(rt->textarea), FALSE);
-  gtk_text_set_line_wrap(GTK_TEXT(rt->textarea), TRUE);
-  gtk_text_set_editable(GTK_TEXT(rt->textarea), FALSE);
-  gtk_widget_show(sw);
-  gtk_scrolled_window_set_policy(scrw, GTK_POLICY_AUTOMATIC, 
-				 GTK_POLICY_AUTOMATIC);
-  gtk_container_add(GTK_CONTAINER(sw), rt->textarea);
-  gtk_widget_show(rt->textarea);
-
-  /* Buttons */
-  hbox = gtk_hbox_new(FALSE, 3);
-  gtk_widget_show(hbox);
-  widget = gtk_button_new_with_label(" Arrêter ");
-  gtk_widget_show(widget);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(kill_trn), rt);
-  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-  widget = gtk_button_new_with_label(" Fermer ");
-  gtk_widget_show(widget);
-  gtk_signal_connect(GTK_OBJECT(widget), "clicked", 
-		     GTK_SIGNAL_FUNC(kill_trn_window), rt);
-  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->action_area), hbox, TRUE,
-		     TRUE, 9);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->vbox), sw, TRUE,
-		     TRUE, 9);
-  
-  gtk_window_set_default_size(GTK_WINDOW(&(GTK_DIALOG(dial)->window)),
-			      340, 280);
-  gtk_widget_show(rt->dialog);
+
+    trn_init(rt);
+
+    /* Main box */
+    dial = rt->dialog = gtk_dialog_new();
+    gtk_widget_hide(dial);
+    gtk_signal_connect(GTK_OBJECT(dial), "destroy",
+                       GTK_SIGNAL_FUNC(kill_trn_window), rt);
+    gtk_window_set_title(GTK_WINDOW(dial), "Suivi d'un tournois");
+    gtk_container_set_border_width(GTK_CONTAINER(&( GTK_DIALOG(dial)->window )),
+                                   7);
+    sw = gtk_scrolled_window_new(NULL, NULL);
+    scrw = GTK_SCROLLED_WINDOW(sw);
+    rt->textarea = gtk_text_new(gtk_scrolled_window_get_hadjustment(scrw),
+                                gtk_scrolled_window_get_vadjustment(scrw));
+    gtk_text_set_word_wrap(GTK_TEXT(rt->textarea), FALSE);
+    gtk_text_set_line_wrap(GTK_TEXT(rt->textarea), TRUE);
+    gtk_text_set_editable(GTK_TEXT(rt->textarea), FALSE);
+    gtk_widget_show(sw);
+    gtk_scrolled_window_set_policy(scrw, GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_container_add(GTK_CONTAINER(sw), rt->textarea);
+    gtk_widget_show(rt->textarea);
+
+    /* Buttons */
+    hbox = gtk_hbox_new(FALSE, 3);
+    gtk_widget_show(hbox);
+    widget = gtk_button_new_with_label(" Arr�ter ");
+    gtk_widget_show(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(kill_trn), rt);
+    gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+    widget = gtk_button_new_with_label(" Fermer ");
+    gtk_widget_show(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "clicked",
+                       GTK_SIGNAL_FUNC(kill_trn_window), rt);
+    gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 9);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->action_area), hbox, TRUE,
+                       TRUE, 9);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dial)->vbox), sw, TRUE,
+                       TRUE, 9);
+
+    gtk_window_set_default_size(GTK_WINDOW(&( GTK_DIALOG(dial)->window )),
+                                340, 280);
+    gtk_widget_show(rt->dialog);
 }
 
 GtkWidget *start_tournois_box()
 {
-  tournois_t *trn;
-  GtkWidget *dialog = NULL, *tbl = NULL, *wid = NULL;
-  GList *l, *maps, *prgs;
-  int nbp, i;
+    tournois_t *trn;
+    GtkWidget *dialog = NULL, *tbl = NULL, *wid = NULL;
+    GList *l, *maps, *prgs;
+    int nbp, i;
+
+    if ( !gl_config->staff )
+    {
+        wid = create_label("Fonctionnalit� r�serv�e aux organisateurs.");
+        return create_dialog("Lancement d'un trounois", wid, NULL,
+                             " Annuler ", NULL, NULL, destroy_widget);
+    }
 
-  if (!gl_config->staff)
+    maps = GTK_CLIST(gl_config->mapl)->selection;
+    if ( maps == NULL )
     {
-      wid = create_label("Fonctionnalité réservée aux organisateurs.");
-      return create_dialog("Lancement d'un trounois", wid, NULL,
-			   " Annuler ", NULL, NULL, destroy_widget);      
+        wid = create_label("Aucune carte s�lectionn�e.");
+        return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL,
+                             destroy_widget);
     }
 
-  maps = GTK_CLIST(gl_config->mapl)->selection;
-  if (maps == NULL)
+    prgs = GTK_CLIST(gl_config->prgl)->selection;
+    if ( prgs == NULL )
+    {
+        wid = create_label("Aucun champion s�lectionn�.");
+        return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL,
+                             destroy_widget);
+    }
+    trn = g_malloc(sizeof(*trn));
+    trn->nbc = g_list_length(prgs);
+    trn->champ = g_malloc(sizeof(*( trn->champ )) * trn->nbc);
+    for ( i = 0, l = prgs ; l != NULL ; l = l->next, i++ )
     {
-      wid = create_label("Aucune carte sélectionnée.");
-      return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL, 
-			   destroy_widget);
+        trn->champ[i] = *((int *)
+                gtk_clist_get_row_data(GTK_CLIST(gl_config->prgl),
+                                       GPOINTER_TO_INT(l->data)));
     }
 
-  prgs = GTK_CLIST(gl_config->prgl)->selection;
-  if (prgs == NULL)
+    trn->mapid = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->mapl),
+                                                  GPOINTER_TO_INT(maps->data)));
+    nbp = mysql_get_int(gl_config->mysql,
+                        "SELECT joueurs FROM Maps where id=%d", trn->mapid);
+
+    tbl = gtk_table_new(2, 5, FALSE);
+    gtk_widget_show(tbl);
+    dialog = create_dialog("Lancement d'un tournois", tbl, " Valider ",
+                           " Annuler ", run_trn_commit, trn, destroy_widget);
+
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Tours: "),
+                              0, 1, 0, 1);
+    trn->nbt = create_spin(1, 5000, 200);
+    gtk_tooltips_set_tip(gl_config->tooltips, trn->nbt,
+                         "Nombre de tours que dureront les parties", "");
+    gtk_table_attach_defaults(GTK_TABLE(tbl), trn->nbt, 1, 2, 0, 1);
+
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Joueurs: "),
+                              0, 1, 1, 2);
+    trn->nbp = create_spin(1, MIN(nbp, trn->nbc), MIN(nbp, trn->nbc));
+    gtk_tooltips_set_tip(gl_config->tooltips, trn->nbp,
+                         "Nombre de joueurs par partie", "");
+    gtk_table_attach_defaults(GTK_TABLE(tbl), trn->nbp, 1, 2, 1, 2);
+
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Nb matchs: "),
+                              0, 1, 3, 4);
+    trn->nbm = create_spin(1, 10000, trn->nbc * 2);
+    gtk_tooltips_set_tip(gl_config->tooltips, trn->nbm,
+                         "Nombre de matchs maximum", "");
+    gtk_table_attach_defaults(GTK_TABLE(tbl), trn->nbm, 1, 2, 3, 4);
+
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label("Param�tres: "),
+                              0, 1, 4, 5);
+    trn->cmd = create_entry(NULL, 100);
+    gtk_signal_connect(GTK_OBJECT(trn->cmd), "activate",
+                       run_trn_commit, trn);
+    gtk_signal_connect_after(GTK_OBJECT(trn->cmd), "activate",
+                             destroy_widget, dialog);
+    gtk_tooltips_set_tip(gl_config->tooltips, trn->cmd,
+                         "Param�tres suppl�mentaires � passer au serveur", "");
+    gtk_table_attach_defaults(GTK_TABLE(tbl), trn->cmd, 1, 2, 4, 5);
+
+    l = NULL;
+    for ( i = 0 ; trn_met[i] != NULL ; i++ )
     {
-      wid = create_label("Aucun champion sélectionné.");
-      return create_dialog("Erreur", wid, NULL, " Fermer ", NULL, NULL, 
-			   destroy_widget);
+        l = g_list_append(l, trn_met[i]);
     }
-  trn = g_malloc(sizeof(*trn));
-  trn->nbc = g_list_length(prgs);
-  trn->champ = g_malloc(sizeof(*(trn->champ)) * trn->nbc);
-  for (i = 0, l = prgs; l != NULL; l = l->next, i++)
-    trn->champ[i] = *((int *) 
-		      gtk_clist_get_row_data(GTK_CLIST(gl_config->prgl), 
-					     GPOINTER_TO_INT(l->data)));
-
-  trn->mapid = *((int *) gtk_clist_get_row_data(GTK_CLIST(gl_config->mapl), 
-						GPOINTER_TO_INT(maps->data)));
-  nbp = mysql_get_int(gl_config->mysql,
-		      "SELECT joueurs FROM Maps where id=%d", trn->mapid);
-
-  tbl = gtk_table_new(2, 5, FALSE);
-  gtk_widget_show(tbl);
-  dialog = create_dialog("Lancement d'un tournois", tbl, " Valider ", 
-			 " Annuler ", run_trn_commit, trn, destroy_widget);
-
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Tours: "),
-			    0, 1, 0, 1);
-  trn->nbt = create_spin(1, 5000, 200);
-  gtk_tooltips_set_tip(gl_config->tooltips, trn->nbt, 
-		       "Nombre de tours que dureront les parties", "");
-  gtk_table_attach_defaults(GTK_TABLE(tbl), trn->nbt, 1, 2, 0, 1);
-
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Joueurs: "),
-			    0, 1, 1, 2);
-  trn->nbp = create_spin(1, MIN(nbp, trn->nbc), MIN(nbp, trn->nbc));
-  gtk_tooltips_set_tip(gl_config->tooltips, trn->nbp, 
-		       "Nombre de joueurs par partie", "");
-  gtk_table_attach_defaults(GTK_TABLE(tbl), trn->nbp, 1, 2, 1, 2);
-
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Nb matchs: "),
-			    0, 1, 3, 4);
-  trn->nbm = create_spin(1, 10000, trn->nbc * 2);
-  gtk_tooltips_set_tip(gl_config->tooltips, trn->nbm, 
-		       "Nombre de matchs maximum", "");
-  gtk_table_attach_defaults(GTK_TABLE(tbl), trn->nbm, 1, 2, 3, 4);
-
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label("Paramètres: "),
-			    0, 1, 4, 5);
-  trn->cmd = create_entry(NULL, 100);
-  gtk_signal_connect(GTK_OBJECT(trn->cmd), "activate", 
-		     run_trn_commit, trn);
-  gtk_signal_connect_after(GTK_OBJECT(trn->cmd), "activate", 
-			   destroy_widget, dialog);
-  gtk_tooltips_set_tip(gl_config->tooltips, trn->cmd, 
-		       "Paramètres supplémentaires à passer au serveur", "");
-  gtk_table_attach_defaults(GTK_TABLE(tbl), trn->cmd, 1, 2, 4, 5);
-
-  l = NULL;
-  for (i = 0; trn_met[i] != NULL; i++)
-    l = g_list_append(l, trn_met[i]);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" Méthode: "),
-			    0, 1, 2, 3);  
-  wid = gtk_combo_new();
-  gtk_widget_show(wid);
-  gtk_tooltips_set_tip(gl_config->tooltips, GTK_COMBO(wid)->entry, 
-		       "Méthode d'exécution des matchs", "");
-  gtk_combo_set_popdown_strings(GTK_COMBO(wid), l);
-  gtk_combo_set_value_in_list(GTK_COMBO(wid), TRUE, TRUE);
-  gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid)->entry), l->data);
-  gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid)->entry), FALSE);
-  gtk_table_attach_defaults(GTK_TABLE(tbl), wid, 1, 2, 2, 3);
-  trn->methode = GTK_COMBO(wid)->entry;
-  g_list_free(l);
-
-  gtk_object_set_data_full(GTK_OBJECT(dialog), "42", trn, 
-			   (GtkDestroyNotify) free);
-
-  return dialog;
+    gtk_table_attach_defaults(GTK_TABLE(tbl), create_label(" M�thode: "),
+                              0, 1, 2, 3);
+    wid = gtk_combo_new();
+    gtk_widget_show(wid);
+    gtk_tooltips_set_tip(gl_config->tooltips, GTK_COMBO(wid)->entry,
+                         "M�thode d'ex�cution des matchs", "");
+    gtk_combo_set_popdown_strings(GTK_COMBO(wid), l);
+    gtk_combo_set_value_in_list(GTK_COMBO(wid), TRUE, TRUE);
+    gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid)->entry), l->data);
+    gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid)->entry), FALSE);
+    gtk_table_attach_defaults(GTK_TABLE(tbl), wid, 1, 2, 2, 3);
+    trn->methode = GTK_COMBO(wid)->entry;
+    g_list_free(l);
+
+    gtk_object_set_data_full(GTK_OBJECT(dialog), "42", trn,
+                             (GtkDestroyNotify) free);
+
+    return dialog;
 }
 

+ 14 - 0
pulsarnet/CMakeLists.txt

@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(PulsarNet)
+
+set(TARGET pulsarnet)
+
+set(TARGET_HEADER_FILES net_private.h)
+set(TARGET_SOURCE_FILES check.c error.c misc.c open.c read.c write.c)
+
+add_library(${TARGET} ${TARGET_SOURCE_FILES} ${TARGET_HEADER_FILES})
+
+target_compile_options(${TARGET} PRIVATE -rdynamic)
+
+install(TARGETS ${TARGET} RUNTIME DESTINATION "lib")

+ 0 - 8
pulsarnet/Makefile.am

@@ -1,8 +0,0 @@
-# $Id: Makefile.am,v 1.3 2001/04/10 17:17:03 kilobug Exp $
-
-INCLUDES = @GLIB_CFLAGS@
-
-noinst_LIBRARIES	= libnet.a
-libnet_a_SOURCES	= open.c write.c read.c net.h net_private.h check.c\
-			  misc.c error.c
-libnet_a_DEPENDENCIES	= ../general.h

+ 54 - 41
pulsarnet/check.c

@@ -1,66 +1,79 @@
-/* $Id: check.c,v 1.5 2001/04/29 17:45:19 kilobug Exp $ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdarg.h>
 
 #include "net_private.h"
 
-gboolean net_chk_string(int fd, const char *s)
+bool net_chk_string(int fd, const char *s)
 {
-  char *st;
-  gboolean res;
+    char *st;
+    bool res;
 
-  if (s == NULL)
-    return FALSE;
-  st = net_get_string(fd);
-  if (st == NULL)
-    return FALSE;
-  res = strcmp(s, st);
-  g_free(st);
-  return !res;
+    if ( s == NULL )
+    {
+        return false;
+    }
+    st = net_get_string(fd);
+    if ( st == NULL )
+    {
+        return false;
+    }
+    res = strcmp(s, st);
+    free(st);
+    return !res;
 }
 
 int net_chk_str_list(int fd, ...)
 {
-  va_list va;
-  char *st;
-  const char *s;
-  int res = -1;
-  int i;
+    va_list va;
+    char *st;
+    const char *s;
+    int res = -1;
+    int i;
 
-  va_start(va, fd);
-  st = net_get_string(fd);
-  if (st == NULL)
-    return res;
-  for (i = 0; ; i++)
+    va_start(va, fd);
+    st = net_get_string(fd);
+    if ( st == NULL )
+    {
+        return res;
+    }
+    for ( i = 0 ;; i++ )
     {
-      s = va_arg(va, const char *);
-      if (s == NULL)
-	break;
-      if (!strcmp(s, st))
-	{
-	  res = i;
-	  break;
-	}
+        s = va_arg(va, const char *);
+        if ( s == NULL )
+        {
+            break;
+        }
+        if ( !strcmp(s, st))
+        {
+            res = i;
+            break;
+        }
     }
-  va_end(va);
-  g_free(st);
-  return res;
+    va_end(va);
+    free(st);
+    return res;
 }
 
-gboolean net_chk_int(int fd, int val)
+bool net_chk_int(int fd, int val)
 {
-  return (val == net_get_int(fd));
+    return (val == net_get_int(fd));
 }
 
-gboolean net_chk_flag(int fd, gboolean val)
+bool net_chk_flag(int fd, bool val)
 {
-  return (val == net_get_flag(fd));
+    return (val == net_get_flag(fd));
 }
 
-gboolean net_chk_char(int fd, char c)
+bool net_chk_char(int fd, char c)
 {
-  return (c == net_get_char(c));
+    return (c == net_get_char(c));
 }
 
-gboolean net_chk_float(int fd, float f)
+bool net_chk_float(int fd, float f)
 {
-  return (f == net_get_char(f));
+    return (f == net_get_char(f));
 }

+ 26 - 20
pulsarnet/error.c

@@ -1,4 +1,6 @@
-/* $Id: error.c,v 1.2 2001/04/29 17:35:17 kilobug Exp $ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include "net_private.h"
 
@@ -7,38 +9,42 @@ static void *gl_net_error_data = NULL;
 
 const char *net_type_name(net_type_t t)
 {
-  switch (t)
+    switch ( t )
     {
     case net_type_str:
-      return "string";
+        return "string";
     case net_type_int:
-      return "integer";
+        return "integer";
     case net_type_float:
-      return "float";
+        return "float";
     case net_type_char:
-      return "char";
+        return "char";
     case net_type_none:
-      return "(none)";
+        return "(none)";
     default:
-      return "(unkown)";
+        return "(unkown)";
     }
 }
 
 void net_set_error_handler(net_error_hdlr_t *hdlr, void *data)
 {
-  if (hdlr != NULL)
-    gl_net_error_handler = hdlr;
-  else
-    gl_net_error_handler = net_error_ignore;
-  gl_net_error_data = data;
+    if ( hdlr != NULL )
+    {
+        gl_net_error_handler = hdlr;
+    }
+    else
+    {
+        gl_net_error_handler = net_error_ignore;
+    }
+    gl_net_error_data = data;
 }
 
 void net_error_abort(net_type_t get, net_type_t wanted, void *data)
 {
-  fprintf(stderr, 
-	  "Fatal protocol error (was %s, excepted %s). Aborting.\n",
-	  net_type_name(get), net_type_name(wanted));
-  exit(2);
+    fprintf(stderr,
+            "Fatal protocol error (was %s, excepted %s). Aborting.\n",
+            net_type_name(get), net_type_name(wanted));
+    exit(2);
 }
 
 void net_error_ignore(net_type_t get, net_type_t wanted, void *data)
@@ -48,8 +54,8 @@ void net_error_ignore(net_type_t get, net_type_t wanted, void *data)
 void net_error(net_type_t get, net_type_t wanted)
 {
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Type error: got %#.2x (%s), wanted %#.2x (%s)\n", 
-	  get, net_type_name(get), wanted, net_type_name(wanted));
+    fprintf(stderr, "Type error: got %#.2x (%s), wanted %#.2x (%s)\n",
+        get, net_type_name(get), wanted, net_type_name(wanted));
 #endif
-  gl_net_error_handler(get, wanted, gl_net_error_data);
+    gl_net_error_handler(get, wanted, gl_net_error_data);
 }

+ 19 - 17
pulsarnet/misc.c

@@ -1,37 +1,39 @@
-/* $Id: misc.c,v 1.4 2001/04/29 15:44:12 kilobug Exp $ */
-
 #include "net_private.h"
 
-#define NET_ACK		0x42034212
-#define NET_ABORT	0x42004200
+#define NET_ACK      0x42034212
+#define NET_ABORT    0x42004200
 
-gboolean net_wait_ack(int fd)
+bool net_wait_ack(int fd)
 {
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Waiting for ACK\n");
+    fprintf(stderr, "Waiting for ACK\n");
 #endif
-  return net_chk_int(fd, NET_ACK);
+    return net_chk_int(fd, NET_ACK);
 }
 
 void net_send_ack(FILE *file)
 {
-  if (file == NULL)
-    return;
+    if ( file == NULL )
+    {
+        return;
+    }
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Sending ACK\n");
+    fprintf(stderr, "Sending ACK\n");
 #endif
-  net_wr_int(file, NET_ACK);
-  fflush(file);
+    net_wr_int(file, NET_ACK);
+    fflush(file);
 }
 
 void net_send_abort(FILE *file)
 {
-  if (file == NULL)
-    return;
+    if ( file == NULL )
+    {
+        return;
+    }
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Sending ERROR\n");
+    fprintf(stderr, "Sending ERROR\n");
 #endif
-  net_wr_int(file, NET_ABORT);  
-  fflush(file);
+    net_wr_int(file, NET_ABORT);
+    fflush(file);
 }
 

+ 2 - 3
pulsarnet/net_private.h

@@ -1,5 +1,3 @@
-/* $Id: net_private.h,v 1.6 2001/05/02 16:42:05 kilobug Exp $ */
-
 #ifndef __PROLO_NET_PRIVATE_H__
 #define __PROLO_NET_PRIVATE_H__
 
@@ -9,7 +7,8 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include "net.h"
+
+#include <pulsarnet.h>
 
 void net_error(net_type_t get, net_type_t wanted);
 

+ 61 - 44
pulsarnet/open.c

@@ -1,63 +1,80 @@
-/* $Id: open.c,v 1.6 2001/04/12 19:38:39 kilobug Exp $ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <errno.h>
 
 #include "net_private.h"
 
 int net_connect_to(const char *host, int port, char *err, int errsz,
-		   struct timeval *to)
+                   struct timeval *to)
 {
-  struct sockaddr_in sin;
-  struct hostent *hp;
-  int fd;
-  
-  if ((hp = gethostbyname(host)) == NULL) 
-    { 
-      if (err != NULL)
-	snprintf(err, errsz, "%s: machine non trouvée.", host);
-      return -1;
+    struct sockaddr_in sin;
+    struct hostent *hp;
+    int fd;
+
+    if (( hp = gethostbyname(host)) == NULL )
+    {
+        if ( err != NULL )
+        {
+            snprintf(err, errsz, "%s: machine non trouv�e.", host);
+        }
+        return -1;
+    }
+    bcopy(hp->h_addr_list, (char *) &sin.sin_addr, hp->h_length);
+    sin.sin_family = hp->h_addrtype;
+    sin.sin_port = htons(port);
+    if (( fd = socket(hp->h_addrtype, SOCK_STREAM, 0)) == -1 )
+    {
+        if ( err != NULL )
+        {
+            snprintf(err, errsz, "socket: %s.", strerror(errno));
+        }
+        return -1;
     }
-  bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length); 
-  sin.sin_family = hp->h_addrtype;
-  sin.sin_port = htons(port);
-  if ((fd = socket(hp->h_addrtype, SOCK_STREAM, 0)) == -1)
-    { 
-      if (err != NULL)
-	snprintf(err, errsz, "socket: %s.", strerror(errno));
-      return -1;
+    if ( to != NULL )
+    {
+        setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, to, sizeof(*to));
     }
-  if (to != NULL)
-    setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, to, sizeof(*to)); 
-  if (connect(fd, (struct sockaddr *)&sin, sizeof (sin)) == -1)
-    { 
-      if (err != NULL)
-	snprintf(err, errsz, "connect: %s.", strerror(errno));
-      return -1;
+    if ( connect(fd, (struct sockaddr *) &sin, sizeof(sin)) == -1 )
+    {
+        if ( err != NULL )
+        {
+            snprintf(err, errsz, "connect: %s.", strerror(errno));
+        }
+        return -1;
     }
-  return fd;
+    return fd;
 }
 
 int net_listen_at(int port, int max_con, char *err, int errsz)
 {
-  int fd;
-  struct sockaddr_in sin;
-  int value = 1;
+    int fd;
+    struct sockaddr_in sin;
+    int value = 1;
 
-  if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+    if (( fd = socket(AF_INET, SOCK_STREAM, 0)) == -1 )
     {
-      if (err != NULL)
-	snprintf(err, errsz, "socket: %s.", strerror(errno));
-      return -1;
+        if ( err != NULL )
+        {
+            snprintf(err, errsz, "socket: %s.", strerror(errno));
+        }
+        return -1;
     }
-  sin.sin_family = AF_INET;
-  sin.sin_port = htons(port);
-  sin.sin_addr.s_addr = INADDR_ANY;
-  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value));
-  if (bind(fd, (struct sockaddr *)&sin, sizeof (sin)) == -1)
+    sin.sin_family = AF_INET;
+    sin.sin_port = htons(port);
+    sin.sin_addr.s_addr = INADDR_ANY;
+    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value));
+    if ( bind(fd, (struct sockaddr *) &sin, sizeof(sin)) == -1 )
     {
-      if (err != NULL)
-	snprintf(err, errsz, "bind: %s.", strerror(errno));
-      return -1;
+        if ( err != NULL )
+        {
+            snprintf(err, errsz, "bind: %s.", strerror(errno));
+        }
+        return -1;
     }
-  listen(fd, max_con);
-  return (fd);
+    listen(fd, max_con);
+    return ( fd );
 }
 

+ 85 - 65
pulsarnet/read.c

@@ -1,123 +1,143 @@
-/* $Id: read.c,v 1.14 2001/04/30 16:02:07 kilobug Exp $ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <errno.h>
+#include <unistd.h>
 
 #include "net_private.h"
 
-static gboolean net_check_type(int fd, net_type_t wanted)
+static bool net_check_type(int fd, net_type_t wanted)
 {
-  unsigned char c = 42;
+    unsigned char c = 42;
 
-  if (read(fd, &c, 1) != 1)
-    c = net_type_none;
+    if ( read(fd, &c, 1) != 1 )
+    {
+        c = net_type_none;
+    }
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Reading type: %#x (wanted: %#x)\n", c, wanted);
+    fprintf(stderr, "Reading type: %#x (wanted: %#x)\n", c, wanted);
 #endif
-  if (c != wanted)
+    if ( c != wanted )
     {
-      net_error(c, wanted);
-      return FALSE;
+        net_error(c, wanted);
+        return false;
     }
-  return TRUE;
+    return true;
 }
 
-static gboolean read_data(int fd, void *buf, int sz)
+static bool read_data(int fd, void *buf, int sz)
 {
-  int i;
-  char *p = buf;
+    int i;
+    char *p = buf;
 
-  while (sz > 0)
+    while ( sz > 0 )
     {
-      i = read(fd, p, sz);
-      if (i <= -1)
-	return FALSE;
-      p += i;
-      sz -= i;
+        i = read(fd, p, sz);
+        if ( i <= -1 )
+        {
+            return false;
+        }
+        p += i;
+        sz -= i;
     }
-  return TRUE;
+    return true;
 }
 
 char *net_get_string(int fd)
 {
-  int sz;
-  char *s;
+    int sz;
+    char *s;
 
-  if (!net_check_type(fd, net_type_str))
-    return NULL;
-  read_data(fd, &sz, 4);
-  sz = g_ntohl(sz);
-  if (sz < 0)
+    if ( !net_check_type(fd, net_type_str))
+    {
+        return NULL;
+    }
+    read_data(fd, &sz, 4);
+    sz = ntohl(sz);
+    if ( sz < 0 )
+    {
+        net_error(net_type_none, net_type_str);
+        return NULL;
+    }
+    if ( sz == 0 )
     {
-      net_error(net_type_none, net_type_str);
-      return NULL;
+        return strdup("");
     }
-  if (sz == 0)
-    return g_strdup("");
-  s = g_malloc(sz + 1);
-  if (!read_data(fd, s, sz))
+    s = malloc(sz + 1);
+    if ( !read_data(fd, s, sz))
     {
-      g_free(s);
-      net_error(net_type_none, net_type_str);
-      return NULL;
+        free(s);
+        net_error(net_type_none, net_type_str);
+        return NULL;
     }
-  s[sz] = 0;
+    s[sz] = 0;
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Reading string: %s\n", s);
+    fprintf(stderr, "Reading string: %s\n", s);
 #endif
-  return s;
+    return s;
 }
 
 int net_get_int(int fd)
 {
-  int l;
+    int l;
 
-  if (!net_check_type(fd, net_type_int))
-    return -1;
-  if (!read_data(fd, &l, 4))
+    if ( !net_check_type(fd, net_type_int))
     {
-      net_error(net_type_none, net_type_int);
-      return -1;
+        return -1;
+    }
+    if ( !read_data(fd, &l, 4))
+    {
+        net_error(net_type_none, net_type_int);
+        return -1;
     }
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Reading int: %d\n", g_ntohl(l));
+    fprintf(stderr, "Reading int: %d\n", ntohl(l));
 #endif
-  return g_ntohl(l);
+    return ntohl(l);
 }
 
-gboolean net_get_flag(int fd)
+bool net_get_flag(int fd)
 {
-  return net_get_char(fd);
+    return net_get_char(fd);
 }
 
 char net_get_char(int fd)
 {
-  char c;
+    char c;
 
-  if (!net_check_type(fd, net_type_char))
-    return FALSE;
-  if (read(fd, &c, 1) != 1)
+    if ( !net_check_type(fd, net_type_char))
+    {
+        return false;
+    }
+    if ( read(fd, &c, 1) != 1 )
     {
-      net_error(net_type_none, net_type_char);
-      return 0;
+        net_error(net_type_none, net_type_char);
+        return 0;
     }
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Reading char: %d\n", c);
+    fprintf(stderr, "Reading char: %d\n", c);
 #endif
-  return c;
+    return c;
 }
 
 float net_get_float(int fd)
 {
-  float f;
+    float f;
 
-  if (!net_check_type(fd, net_type_float))
-    return 1;
-  if (!read_data(fd, &f, 4))
+    if ( !net_check_type(fd, net_type_float))
+    {
+        return 1;
+    }
+    if ( !read_data(fd, &f, 4))
     {
-      net_error(net_type_none, net_type_float);
-      return 1;
+        net_error(net_type_none, net_type_float);
+        return 1;
     }
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Reading float: %f\n", f);
+    fprintf(stderr, "Reading float: %f\n", f);
 #endif
-  return f;
+    return f;
 }
 

+ 63 - 41
pulsarnet/write.c

@@ -1,79 +1,101 @@
-/* $Id: write.c,v 1.13 2001/04/30 16:02:07 kilobug Exp $ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <errno.h>
+#include <unistd.h>
 
 #include "net_private.h"
 
 static void net_write_type(FILE *file, net_type_t type)
 {
-  unsigned char c;
+    unsigned char c;
 
-  if (file == NULL)
-    return;
-  c = type;
+    if ( file == NULL )
+    {
+        return;
+    }
+    c = type;
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Writing type: %#x\n", c);
+    fprintf(stderr, "Writing type: %#x\n", c);
 #endif
-  fwrite(&c, 1, 1, file);
+    fwrite(&c, 1, 1, file);
 }
 
 void net_wr_string(FILE *file, const char *s)
 {
-  int l;
+    int l;
 
-  if (file == NULL)
-    return;
-  net_write_type(file, net_type_str);
+    if ( file == NULL )
+    {
+        return;
+    }
+    net_write_type(file, net_type_str);
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Sending string: %s\n", s);
+    fprintf(stderr, "Sending string: %s\n", s);
 #endif
-  if (s == NULL)
-    l = 0;
-  else
-    l = strlen(s);
-  l = g_htonl(l);
-  fwrite(&l, 4, 1, file);;
-  l = g_ntohl(l);
-  fwrite(s, 1, l, file);;
+    if ( s == NULL )
+    {
+        l = 0;
+    }
+    else
+    {
+        l = strlen(s);
+    }
+    l = htonl(l);
+    fwrite(&l, 4, 1, file);;
+    l = ntohl(l);
+    fwrite(s, 1, l, file);;
 }
 
 void net_wr_int(FILE *file, int val)
 {
-  int l;
+    int l;
 
-  if (file == NULL)
-    return;
-  net_write_type(file, net_type_int);
+    if ( file == NULL )
+    {
+        return;
+    }
+    net_write_type(file, net_type_int);
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Sending int: %d\n", val);
+    fprintf(stderr, "Sending int: %d\n", val);
 #endif
-  l = g_htonl(val);
-  fwrite(&l, 4, 1, file);;
+    l = htonl(val);
+    fwrite(&l, 4, 1, file);;
 }
 
-void net_wr_flag(FILE *file, gboolean val)
+void net_wr_flag(FILE *file, bool val)
 {
-  if (file == NULL)
-    return;
-  net_wr_char(file, val);
+    if ( file == NULL )
+    {
+        return;
+    }
+    net_wr_char(file, val);
 }
 
 void net_wr_char(FILE *file, char c)
 {
-  if (file == NULL)
-    return;
-  net_write_type(file, net_type_char);
+    if ( file == NULL )
+    {
+        return;
+    }
+    net_write_type(file, net_type_char);
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Sending char: %d\n", c);
+    fprintf(stderr, "Sending char: %d\n", c);
 #endif
-  fwrite(&c, 1, 1, file);
+    fwrite(&c, 1, 1, file);
 }
 
 void net_wr_float(FILE *file, float f)
 {
-  if (file == NULL)
-    return;
-  net_write_type(file, net_type_float);
+    if ( file == NULL )
+    {
+        return;
+    }
+    net_write_type(file, net_type_float);
 #ifdef __DEBUG_NETLIB__
-  fprintf(stderr, "Sending float: %f\n", f);
+    fprintf(stderr, "Sending float: %f\n", f);
 #endif
-  fwrite(&f, 4, 1, file);
+    fwrite(&f, 4, 1, file);
 }

+ 1 - 1
server/CMakeLists.txt

@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.10)
 
 project(PulsarServer)
 

+ 467 - 467
server/client.c

@@ -14,723 +14,723 @@
 
 int turn_number(void)
 {
-   return gl_config->nb_turns;
+    return gl_config->nb_turns;
 }
 
 int turn_counter(void)
 {
-   return gl_config->turn_num;
+    return gl_config->turn_num;
 }
 
 static boolean_t is_visible(int team_id, float x, float y)
 {
-   return (get_pulse_total(x, y, team_id) >= gl_config->see_power);
-   /* AVANT MODIF MATHIAS  return (get_pulse_team(x, y, team_id) >= gl_config->see_power); */
+    return ( get_pulse_total(x, y, team_id) >= gl_config->see_power );
+    /* AVANT MODIF MATHIAS  return (get_pulse_team(x, y, team_id) >= gl_config->see_power); */
 }
 
 static boolean_t is_obj_visible(int team_id, int id)
 {
-   if (glbObjects[id].obj.team_id == team_id)
-   {
-      return True;
-   }
-   return is_visible(team_id, glbObjects[id].obj.x, glbObjects[id].obj.y);
+    if ( glbObjects[id].obj.team_id == team_id )
+    {
+        return True;
+    }
+    return is_visible(team_id, glbObjects[id].obj.x, glbObjects[id].obj.y);
 }
 
 void set_default_action_r4d2(int r4d2_id)
 {
-   glbObjects[r4d2_id].r4d2.action.type = act_r4d2_move;
-   glbObjects[r4d2_id].r4d2.action.act.move.x = glbObjects[r4d2_id].r4d2.x;
-   glbObjects[r4d2_id].r4d2.action.act.move.y = glbObjects[r4d2_id].r4d2.y;
+    glbObjects[r4d2_id].r4d2.action.type = act_r4d2_move;
+    glbObjects[r4d2_id].r4d2.action.act.move.x = glbObjects[r4d2_id].r4d2.x;
+    glbObjects[r4d2_id].r4d2.action.act.move.y = glbObjects[r4d2_id].r4d2.y;
 }
 
 void set_default_action_akx(int akx_id)
 {
-   glbObjects[akx_id].akx.action.type = act_akx_move;
-   glbObjects[akx_id].akx.action.act.move.x = glbObjects[akx_id].akx.x;
-   glbObjects[akx_id].akx.action.act.move.y = glbObjects[akx_id].akx.y;
+    glbObjects[akx_id].akx.action.type = act_akx_move;
+    glbObjects[akx_id].akx.action.act.move.x = glbObjects[akx_id].akx.x;
+    glbObjects[akx_id].akx.action.act.move.y = glbObjects[akx_id].akx.y;
 }
 
 int time_get_left()
 {
-   return time_left();
+    return time_left();
 }
 
 int error_get()
 {
-   int foo;
+    int foo;
 
-   foo = glbPlayer->error;
-   glbPlayer->error = NONE;
-   return foo;
+    foo = glbPlayer->error;
+    glbPlayer->error = NONE;
+    return foo;
 }
 
 int score_get()
 {
-   return (int)glbPlayer->score;
+    return (int) glbPlayer->score;
 }
 
 static boolean_t validate_object(int obj_id, obj_type_t type)
 {
-   if ((obj_id >= gl_config->nb_objects) || (obj_id < 0))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return False;
-   }
-   if (!is_obj_visible(glbPlayer->team_id, obj_id))
-   {
-      glbPlayer->error = NOT_VISIBLE;
-      return False;
-   }
-   if (glbObjects[obj_id].obj.type != type)
-   {
-      glbPlayer->error = TYPE_ERROR;
-      return False;
-   }
-   return True;
+    if (( obj_id >= gl_config->nb_objects ) || ( obj_id < 0 ))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return False;
+    }
+    if ( !is_obj_visible(glbPlayer->team_id, obj_id))
+    {
+        glbPlayer->error = NOT_VISIBLE;
+        return False;
+    }
+    if ( glbObjects[obj_id].obj.type != type )
+    {
+        glbPlayer->error = TYPE_ERROR;
+        return False;
+    }
+    return True;
 }
 
 static boolean_t validate_object_nosee(int obj_id, obj_type_t type)
 {
-   if ((obj_id >= gl_config->nb_objects) || (obj_id < 0))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return False;
-   }
-   if (glbObjects[obj_id].obj.type != type)
-   {
-      glbPlayer->error = TYPE_ERROR;
-      return False;
-   }
-   return True;
+    if (( obj_id >= gl_config->nb_objects ) || ( obj_id < 0 ))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return False;
+    }
+    if ( glbObjects[obj_id].obj.type != type )
+    {
+        glbPlayer->error = TYPE_ERROR;
+        return False;
+    }
+    return True;
 }
 
 static boolean_t validate_object_owner(int obj_id, obj_type_t type)
 {
-   if ((obj_id >= gl_config->nb_objects) || (obj_id < 0))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return False;
-   }
-   if (glbObjects[obj_id].obj.team_id != glbPlayer->team_id)
-   {
-      if ((glbObjects[obj_id].obj.team_id == 0) && (type == obj_r4d2))
-      {
-         glbPlayer->error = DESTROYED;
-      }
-      else
-      {
-         glbPlayer->error = NOT_YOURS;
-      }
-      return False;
-   }
-   if (glbObjects[obj_id].obj.type != type)
-   {
-      glbPlayer->error = TYPE_ERROR;
-      return False;
-   }
-   return True;
+    if (( obj_id >= gl_config->nb_objects ) || ( obj_id < 0 ))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return False;
+    }
+    if ( glbObjects[obj_id].obj.team_id != glbPlayer->team_id )
+    {
+        if (( glbObjects[obj_id].obj.team_id == 0 ) && ( type == obj_r4d2 ))
+        {
+            glbPlayer->error = DESTROYED;
+        }
+        else
+        {
+            glbPlayer->error = NOT_YOURS;
+        }
+        return False;
+    }
+    if ( glbObjects[obj_id].obj.type != type )
+    {
+        glbPlayer->error = TYPE_ERROR;
+        return False;
+    }
+    return True;
 }
 
 int r4d2_get_team(int r4d2_id)
 {
-   if (!validate_object(r4d2_id, obj_r4d2))
-   {
-      return -1;
-   }
-   if (glbObjects[r4d2_id].obj.team_id == 0)
-   {
-      glbPlayer->error = DESTROYED;
-      return -1;
-   }
-   return glbObjects[r4d2_id].obj.team_id;
+    if ( !validate_object(r4d2_id, obj_r4d2))
+    {
+        return -1;
+    }
+    if ( glbObjects[r4d2_id].obj.team_id == 0 )
+    {
+        glbPlayer->error = DESTROYED;
+        return -1;
+    }
+    return glbObjects[r4d2_id].obj.team_id;
 }
 
 float r4d2_get_pos_x(int r4d2_id)
 {
-   if (!validate_object(r4d2_id, obj_r4d2))
-   {
-      return -1;
-   }
-   return glbObjects[r4d2_id].obj.x;
+    if ( !validate_object(r4d2_id, obj_r4d2))
+    {
+        return -1;
+    }
+    return glbObjects[r4d2_id].obj.x;
 }
 
 float r4d2_get_pos_y(int r4d2_id)
 {
-   if (!validate_object(r4d2_id, obj_r4d2))
-   {
-      return -1;
-   }
-   return glbObjects[r4d2_id].obj.y;
+    if ( !validate_object(r4d2_id, obj_r4d2))
+    {
+        return -1;
+    }
+    return glbObjects[r4d2_id].obj.y;
 }
 
 int r4d2_get_status(int r4d2_id)
 {
-   if (!validate_object(r4d2_id, obj_r4d2))
-   {
-      return -1;
-   }
-   return glbObjects[r4d2_id].r4d2.action.type;
+    if ( !validate_object(r4d2_id, obj_r4d2))
+    {
+        return -1;
+    }
+    return glbObjects[r4d2_id].r4d2.action.type;
 }
 
 float r4d2_get_speed()
 {
-   return gl_config->r4d2_speed;
+    return gl_config->r4d2_speed;
 }
 
 float r4d2_get_destroy_speed()
 {
-   return gl_config->destroy_speed;
+    return gl_config->destroy_speed;
 }
 
 int r4d2_turn_take_r4d2()
 {
-   return gl_config->turn_take_r4d2;
+    return gl_config->turn_take_r4d2;
 }
 
 int r4d2_turn_untake_r4d2()
 {
-   return gl_config->turn_untake_r4d2;
+    return gl_config->turn_untake_r4d2;
 }
 
 int r4d2_turn_take_akx()
 {
-   return gl_config->turn_take_akx;
+    return gl_config->turn_take_akx;
 }
 
 int r4d2_turn_untake_akx()
 {
-   return gl_config->turn_untake_akx;
+    return gl_config->turn_untake_akx;
 }
 
 int r4d2_move(int r4d2_id, float x, float y)
 {
-   if (!finitef(x) || !finitef(y))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   if (!validate_object_owner(r4d2_id, obj_r4d2))
-   {
-      return -1;
-   }
-   glbObjects[r4d2_id].r4d2.action.type = act_r4d2_move;
-   glbObjects[r4d2_id].r4d2.action.act.move.x = x;
-   glbObjects[r4d2_id].r4d2.action.act.move.y = y;
+    if ( !finitef(x) || !finitef(y))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    if ( !validate_object_owner(r4d2_id, obj_r4d2))
+    {
+        return -1;
+    }
+    glbObjects[r4d2_id].r4d2.action.type = act_r4d2_move;
+    glbObjects[r4d2_id].r4d2.action.act.move.x = x;
+    glbObjects[r4d2_id].r4d2.action.act.move.y = y;
 
-   return 0;
+    return 0;
 }
 
 int r4d2_take_akx(int r4d2_id, int target_id)
 {
-   if (!validate_object_owner(r4d2_id, obj_r4d2))
-   {
-      return -1;
-   }
-   if (!validate_object_nosee(target_id, obj_akx))
-   {
-      return -1;
-   }
-   if (map_get_dist(glbObjects[r4d2_id].r4d2.x,
-                    glbObjects[r4d2_id].r4d2.y,
-                    glbObjects[target_id].akx.x,
-                    glbObjects[target_id].akx.y) > DIST_MIN_TAKE)
-   {
-      set_default_action_r4d2(r4d2_id);
-      glbPlayer->error = POS_OUT_OF_RANGE;
-      return -1;
-   }
-   if (glbObjects[r4d2_id].r4d2.action.type == act_r4d2_take_akx)
-   {
-      return 0;
-   }
-   glbObjects[r4d2_id].r4d2.action.type = act_r4d2_take_akx;
-   glbObjects[r4d2_id].r4d2.action.act.take_akx.target_id = target_id;
-   glbObjects[r4d2_id].r4d2.action.act.take_akx.turn_need =
-           gl_config->turn_take_akx;
-   if (glbObjects[target_id].akx.team_id != 0)
-   {
-      glbObjects[r4d2_id].r4d2.action.act.take_akx.turn_need +=
-              gl_config->turn_untake_akx;
-   }
-   return 0;
+    if ( !validate_object_owner(r4d2_id, obj_r4d2))
+    {
+        return -1;
+    }
+    if ( !validate_object_nosee(target_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( map_get_dist(glbObjects[r4d2_id].r4d2.x,
+                      glbObjects[r4d2_id].r4d2.y,
+                      glbObjects[target_id].akx.x,
+                      glbObjects[target_id].akx.y) > DIST_MIN_TAKE )
+    {
+        set_default_action_r4d2(r4d2_id);
+        glbPlayer->error = POS_OUT_OF_RANGE;
+        return -1;
+    }
+    if ( glbObjects[r4d2_id].r4d2.action.type == act_r4d2_take_akx )
+    {
+        return 0;
+    }
+    glbObjects[r4d2_id].r4d2.action.type = act_r4d2_take_akx;
+    glbObjects[r4d2_id].r4d2.action.act.take_akx.target_id = target_id;
+    glbObjects[r4d2_id].r4d2.action.act.take_akx.turn_need =
+            gl_config->turn_take_akx;
+    if ( glbObjects[target_id].akx.team_id != 0 )
+    {
+        glbObjects[r4d2_id].r4d2.action.act.take_akx.turn_need +=
+                gl_config->turn_untake_akx;
+    }
+    return 0;
 }
 
 int r4d2_take_r4d2(int r4d2_id, int target_id)
 {
-   if (!validate_object_owner(r4d2_id, obj_r4d2))
-   {
-      return -1;
-   }
-   if (!validate_object_nosee(target_id, obj_akx))
-   {
-      return -1;
-   }
-   if (target_id == r4d2_id)
-   {
-      glbPlayer->error = INVALID_TARGET;
-      return -1;
-   }
-   if ((glbObjects[target_id].obj.team_id == 0) ||
-       (glbObjects[target_id].obj.team_id > gl_config->nb_players))
-   {
-      glbPlayer->error = DESTROYED;
-      return -1;
-   }
-   if (map_get_dist(glbObjects[r4d2_id].r4d2.x,
-                    glbObjects[r4d2_id].r4d2.y,
-                    glbObjects[target_id].r4d2.x,
-                    glbObjects[target_id].r4d2.y) > DIST_MIN_TAKE)
-   {
-      set_default_action_r4d2(r4d2_id);
-      glbPlayer->error = POS_OUT_OF_RANGE;
-      return -1;
-   }
-   if (glbObjects[r4d2_id].r4d2.action.type == act_r4d2_take_r4d2)
-   {
-      return 0;
-   }
-   glbObjects[r4d2_id].r4d2.action.type = act_r4d2_take_r4d2;
-   glbObjects[r4d2_id].r4d2.action.act.take_r4d2.target_id = target_id;
-   glbObjects[r4d2_id].r4d2.action.act.take_r4d2.turn_need =
-           gl_config->turn_take_r4d2;
-   if (glbObjects[target_id].r4d2.team_id != 0)
-   {
-      glbObjects[r4d2_id].r4d2.action.act.take_r4d2.turn_need +=
-              gl_config->turn_untake_r4d2;
-   }
-   return 0;
+    if ( !validate_object_owner(r4d2_id, obj_r4d2))
+    {
+        return -1;
+    }
+    if ( !validate_object_nosee(target_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( target_id == r4d2_id )
+    {
+        glbPlayer->error = INVALID_TARGET;
+        return -1;
+    }
+    if (( glbObjects[target_id].obj.team_id == 0 ) ||
+        ( glbObjects[target_id].obj.team_id > gl_config->nb_players ))
+    {
+        glbPlayer->error = DESTROYED;
+        return -1;
+    }
+    if ( map_get_dist(glbObjects[r4d2_id].r4d2.x,
+                      glbObjects[r4d2_id].r4d2.y,
+                      glbObjects[target_id].r4d2.x,
+                      glbObjects[target_id].r4d2.y) > DIST_MIN_TAKE )
+    {
+        set_default_action_r4d2(r4d2_id);
+        glbPlayer->error = POS_OUT_OF_RANGE;
+        return -1;
+    }
+    if ( glbObjects[r4d2_id].r4d2.action.type == act_r4d2_take_r4d2 )
+    {
+        return 0;
+    }
+    glbObjects[r4d2_id].r4d2.action.type = act_r4d2_take_r4d2;
+    glbObjects[r4d2_id].r4d2.action.act.take_r4d2.target_id = target_id;
+    glbObjects[r4d2_id].r4d2.action.act.take_r4d2.turn_need =
+            gl_config->turn_take_r4d2;
+    if ( glbObjects[target_id].r4d2.team_id != 0 )
+    {
+        glbObjects[r4d2_id].r4d2.action.act.take_r4d2.turn_need +=
+                gl_config->turn_untake_r4d2;
+    }
+    return 0;
 }
 
 static int get_nearest_not(float x, float y, int id, int team_id,
                            obj_type_t target_type)
 {
-   int nearest = id;
-   float dist_nearest = MAXFLOAT;
-   int cpt;
-   float dist_temp;
-
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      if ((cpt != id) &&
-          (glbObjects[cpt].obj.team_id != team_id) &&
-          (glbObjects[cpt].obj.type == target_type))
-      {
-         if ((target_type != obj_r4d2) || (glbObjects[cpt].obj.team_id != 0))
-         {
-            if (is_obj_visible(glbPlayer->team_id, cpt))
+    int nearest = id;
+    float dist_nearest = MAXFLOAT;
+    int cpt;
+    float dist_temp;
+
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        if (( cpt != id ) &&
+            ( glbObjects[cpt].obj.team_id != team_id ) &&
+            ( glbObjects[cpt].obj.type == target_type ))
+        {
+            if (( target_type != obj_r4d2 ) || ( glbObjects[cpt].obj.team_id != 0 ))
             {
-               dist_temp = map_get_dist(x, y,
-                                        glbObjects[cpt].obj.x,
-                                        glbObjects[cpt].obj.y);
-               if (dist_temp < dist_nearest)
-               {
-                  nearest = cpt;
-                  dist_nearest = dist_temp;
-               }
+                if ( is_obj_visible(glbPlayer->team_id, cpt))
+                {
+                    dist_temp = map_get_dist(x, y,
+                                             glbObjects[cpt].obj.x,
+                                             glbObjects[cpt].obj.y);
+                    if ( dist_temp < dist_nearest )
+                    {
+                        nearest = cpt;
+                        dist_nearest = dist_temp;
+                    }
+                }
             }
-         }
-      }
-   }
-   return nearest;
+        }
+    }
+    return nearest;
 }
 
 static int get_nearest_plot(float x, float y, int id, int team_id,
                             obj_type_t target_type)
 {
-   int nearest = id;
-   float dist_nearest = MAXFLOAT;
-   int cpt;
-   float dist_temp;
-
-   if (team_id < 0)
-   {
-      nearest = get_nearest_not(x, y, id, -team_id, target_type);
-   }
-   else
-   {
-      for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-      {
-         if ((cpt != id) &&
-             (glbObjects[cpt].obj.team_id == team_id) &&
-             (glbObjects[cpt].obj.type == target_type))
-         {
-            if ((target_type != obj_r4d2) || (glbObjects[cpt].obj.team_id > 0))
+    int nearest = id;
+    float dist_nearest = MAXFLOAT;
+    int cpt;
+    float dist_temp;
+
+    if ( team_id < 0 )
+    {
+        nearest = get_nearest_not(x, y, id, -team_id, target_type);
+    }
+    else
+    {
+        for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+        {
+            if (( cpt != id ) &&
+                ( glbObjects[cpt].obj.team_id == team_id ) &&
+                ( glbObjects[cpt].obj.type == target_type ))
             {
-               if (is_obj_visible(glbPlayer->team_id, cpt))
-               {
-                  dist_temp = map_get_dist(x, y,
-                                           glbObjects[cpt].obj.x,
-                                           glbObjects[cpt].obj.y);
-                  if (dist_temp < dist_nearest)
-                  {
-                     nearest = cpt;
-                     dist_nearest = dist_temp;
-                  }
-               }
+                if (( target_type != obj_r4d2 ) || ( glbObjects[cpt].obj.team_id > 0 ))
+                {
+                    if ( is_obj_visible(glbPlayer->team_id, cpt))
+                    {
+                        dist_temp = map_get_dist(x, y,
+                                                 glbObjects[cpt].obj.x,
+                                                 glbObjects[cpt].obj.y);
+                        if ( dist_temp < dist_nearest )
+                        {
+                            nearest = cpt;
+                            dist_nearest = dist_temp;
+                        }
+                    }
+                }
             }
-         }
-      }
-   }
-   return nearest;
+        }
+    }
+    return nearest;
 }
 
 int get_nearest(int id, int team_id, obj_type_t target_type)
 {
-   return get_nearest_plot(glbObjects[id].obj.x,
-                           glbObjects[id].obj.y,
-                           id, team_id, target_type);
+    return get_nearest_plot(glbObjects[id].obj.x,
+                            glbObjects[id].obj.y,
+                            id, team_id, target_type);
 }
 
 int akx_get_team(int akx_id)
 {
-   if (!validate_object(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   return glbObjects[akx_id].obj.team_id;
+    if ( !validate_object(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    return glbObjects[akx_id].obj.team_id;
 }
 
 float akx_get_pos_x(int akx_id)
 {
-   if (!validate_object(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   return glbObjects[akx_id].obj.x;
+    if ( !validate_object(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    return glbObjects[akx_id].obj.x;
 }
 
 float akx_get_pos_y(int akx_id)
 {
-   if (!validate_object(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   return glbObjects[akx_id].obj.y;
+    if ( !validate_object(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    return glbObjects[akx_id].obj.y;
 }
 
 int akx_get_status(int akx_id)
 {
-   if (!validate_object(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   return glbObjects[akx_id].akx.action.type;
+    if ( !validate_object(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    return glbObjects[akx_id].akx.action.type;
 }
 
 
 float akx_get_speed()
 {
-   return gl_config->akx_speed;
+    return gl_config->akx_speed;
 }
 
 float akx_get_power()
 {
-   return gl_config->pulse_power;
+    return gl_config->pulse_power;
 }
 
 float akx_get_see_power()
 {
-   return gl_config->see_power;
+    return gl_config->see_power;
 }
 
 float akx_see_power()
 {
-   return gl_config->see_power;
+    return gl_config->see_power;
 }
 
 float akx_get_pulse_coef()
 {
-   return gl_config->pulse_coef;
+    return gl_config->pulse_coef;
 }
 
 int akx_move(int akx_id, float x, float y)
 {
-   if (!finitef(x) || !finitef(y))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   if (!validate_object_owner(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   glbObjects[akx_id].akx.action.type = act_akx_move;
-   glbObjects[akx_id].akx.action.act.move.x = x;
-   glbObjects[akx_id].akx.action.act.move.y = y;
-   glbObjects[akx_id].akx.change = True;
-   return 0;
+    if ( !finitef(x) || !finitef(y))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    if ( !validate_object_owner(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    glbObjects[akx_id].akx.action.type = act_akx_move;
+    glbObjects[akx_id].akx.action.act.move.x = x;
+    glbObjects[akx_id].akx.action.act.move.y = y;
+    glbObjects[akx_id].akx.change = True;
+    return 0;
 }
 
 int akx_pulse(int akx_id, float x, float y, float angle)
 {
-   if (!finitef(x) || !finitef(y) || !finitef(angle))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   if (!validate_object_owner(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   if (glbObjects[akx_id].akx.action.type != act_akx_pulse)
-   {
-      glbObjects[akx_id].akx.action.act.pulse.x = glbObjects[akx_id].obj.x;
-      glbObjects[akx_id].akx.action.act.pulse.y = glbObjects[akx_id].obj.y;
-      glbObjects[akx_id].akx.energy = 0;
-   }
-   glbObjects[akx_id].akx.action.type = act_akx_pulse;
-   glbObjects[akx_id].akx.action.act.pulse.new_x = x;
-   glbObjects[akx_id].akx.action.act.pulse.new_y = y;
-   glbObjects[akx_id].akx.action.act.pulse.new_angle = CLAMP(angle, MIN_ANGLE, MAX_ANGLE);
-   glbObjects[akx_id].akx.change = True;
-   return 0;
+    if ( !finitef(x) || !finitef(y) || !finitef(angle))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    if ( !validate_object_owner(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( glbObjects[akx_id].akx.action.type != act_akx_pulse )
+    {
+        glbObjects[akx_id].akx.action.act.pulse.x = glbObjects[akx_id].obj.x;
+        glbObjects[akx_id].akx.action.act.pulse.y = glbObjects[akx_id].obj.y;
+        glbObjects[akx_id].akx.energy = 0;
+    }
+    glbObjects[akx_id].akx.action.type = act_akx_pulse;
+    glbObjects[akx_id].akx.action.act.pulse.new_x = x;
+    glbObjects[akx_id].akx.action.act.pulse.new_y = y;
+    glbObjects[akx_id].akx.action.act.pulse.new_angle = CLAMP(angle, MIN_ANGLE, MAX_ANGLE);
+    glbObjects[akx_id].akx.change = True;
+    return 0;
 }
 
 float akx_pulse_angle(int akx_id)
 {
-   if (!validate_object(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   if (glbObjects[akx_id].akx.action.type != act_akx_pulse)
-   {
-      glbPlayer->error = INVALID_TARGET;
-      return -1;
-   }
-   return glbObjects[akx_id].akx.action.act.pulse.angle;
+    if ( !validate_object(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( glbObjects[akx_id].akx.action.type != act_akx_pulse )
+    {
+        glbPlayer->error = INVALID_TARGET;
+        return -1;
+    }
+    return glbObjects[akx_id].akx.action.act.pulse.angle;
 }
 
 float akx_pulse_destx(int akx_id)
 {
-   if (!validate_object(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   if (glbObjects[akx_id].akx.action.type != act_akx_pulse)
-   {
-      glbPlayer->error = INVALID_TARGET;
-      return -1;
-   }
-   return glbObjects[akx_id].akx.action.act.pulse.x;
+    if ( !validate_object(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( glbObjects[akx_id].akx.action.type != act_akx_pulse )
+    {
+        glbPlayer->error = INVALID_TARGET;
+        return -1;
+    }
+    return glbObjects[akx_id].akx.action.act.pulse.x;
 }
 
 float akx_pulse_desty(int akx_id)
 {
-   if (!validate_object(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   if (glbObjects[akx_id].akx.action.type != act_akx_pulse)
-   {
-      glbPlayer->error = INVALID_TARGET;
-      return -1;
-   }
-   return glbObjects[akx_id].akx.action.act.pulse.y;
+    if ( !validate_object(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( glbObjects[akx_id].akx.action.type != act_akx_pulse )
+    {
+        glbPlayer->error = INVALID_TARGET;
+        return -1;
+    }
+    return glbObjects[akx_id].akx.action.act.pulse.y;
 }
 
 int akx_link(int akx_id, int target_id)
 {
-   if (!validate_object_owner(akx_id, obj_akx))
-   {
-      return -1;
-   }
-   if (!validate_object_owner(target_id, obj_akx))
-   {
-      return -1;
-   }
-   if (target_id == akx_id)
-   {
-      glbPlayer->error = INVALID_TARGET;
-      return -1;
-   }
-   glbObjects[akx_id].akx.change = True;
-   set_default_action_akx(akx_id);
-   glbObjects[akx_id].akx.action.type = act_akx_link;
-   glbObjects[akx_id].akx.action.act.link.target_id = target_id;
-   return 0;
+    if ( !validate_object_owner(akx_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( !validate_object_owner(target_id, obj_akx))
+    {
+        return -1;
+    }
+    if ( target_id == akx_id )
+    {
+        glbPlayer->error = INVALID_TARGET;
+        return -1;
+    }
+    glbObjects[akx_id].akx.change = True;
+    set_default_action_akx(akx_id);
+    glbObjects[akx_id].akx.action.type = act_akx_link;
+    glbObjects[akx_id].akx.action.act.link.target_id = target_id;
+    return 0;
 }
 
 int map_get_nearest_akx(int id, int team_id)
 {
-   int nearest;
+    int nearest;
 
-   if (id >= gl_config->nb_objects)
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   nearest = get_nearest(id, team_id, obj_akx);
-   if (nearest == id)
-   {
-      glbPlayer->error = NOT_VISIBLE;
-      return -1;
-   }
-   return nearest;
+    if ( id >= gl_config->nb_objects )
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    nearest = get_nearest(id, team_id, obj_akx);
+    if ( nearest == id )
+    {
+        glbPlayer->error = NOT_VISIBLE;
+        return -1;
+    }
+    return nearest;
 }
 
 int map_get_nearest_akx_plot(float x, float y, int team_id)
 {
-   int nearest;
+    int nearest;
 
-   if (!finitef(x) || !finitef(y))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   nearest = get_nearest_plot(x, y, -1, team_id, obj_akx);
-   if (nearest == -1)
-   {
-      glbPlayer->error = NOT_VISIBLE;
-      return -1;
-   }
-   return nearest;
+    if ( !finitef(x) || !finitef(y))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    nearest = get_nearest_plot(x, y, -1, team_id, obj_akx);
+    if ( nearest == -1 )
+    {
+        glbPlayer->error = NOT_VISIBLE;
+        return -1;
+    }
+    return nearest;
 }
 
 int map_get_nearest_r4d2_plot(float x, float y, int team_id)
 {
-   int nearest;
+    int nearest;
 
-   if (!finitef(x) || !finitef(y))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   nearest = get_nearest_plot(x, y, -1, team_id, obj_r4d2);
-   if (nearest == -1)
-   {
-      glbPlayer->error = NOT_VISIBLE;
-      return -1;
-   }
-   return nearest;
+    if ( !finitef(x) || !finitef(y))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    nearest = get_nearest_plot(x, y, -1, team_id, obj_r4d2);
+    if ( nearest == -1 )
+    {
+        glbPlayer->error = NOT_VISIBLE;
+        return -1;
+    }
+    return nearest;
 }
 
 int map_get_nearest_r4d2(int id, int team_id)
 {
-   int nearest;
+    int nearest;
 
-   if (id >= gl_config->nb_objects)
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   nearest = get_nearest(id, team_id, obj_r4d2);
-   if (nearest == id)
-   {
-      glbPlayer->error = NOT_VISIBLE;
-      return -1;
-   }
-   return nearest;
+    if ( id >= gl_config->nb_objects )
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    nearest = get_nearest(id, team_id, obj_r4d2);
+    if ( nearest == id )
+    {
+        glbPlayer->error = NOT_VISIBLE;
+        return -1;
+    }
+    return nearest;
 }
 
 int map_count_akx()
 {
-   return gl_config->nb_akx;
+    return gl_config->nb_akx;
 }
 
 int map_count_r4d2()
 {
-   return gl_config->nb_r4d2;
+    return gl_config->nb_r4d2;
 }
 
 int count_unit(int team_id, int obj_type)
 {
-   int cpt = 0, i;
+    int cpt = 0, i;
 
-   for (i = 0 ; i < gl_config->nb_objects ; i++)
-   {
-      if ((glbObjects[i].obj.team_id == team_id) &&
-          (glbObjects[i].obj.type == obj_type))
-      {
-         cpt++;
-      }
-   }
-   return cpt;
+    for ( i = 0 ; i < gl_config->nb_objects ; i++ )
+    {
+        if (( glbObjects[i].obj.team_id == team_id ) &&
+            ( glbObjects[i].obj.type == obj_type ))
+        {
+            cpt++;
+        }
+    }
+    return cpt;
 }
 
 int count_akx(int team_id)
 {
-   return count_unit(team_id, obj_akx);
+    return count_unit(team_id, obj_akx);
 }
 
 int map_count_my_akx()
 {
-   return count_akx(glbPlayer->team_id);
+    return count_akx(glbPlayer->team_id);
 }
 
 int count_r4d2(int team_id)
 {
-   return count_unit(team_id, obj_r4d2);
+    return count_unit(team_id, obj_r4d2);
 }
 
 float map_get_size_x()
 {
-   return gl_config->size_x;
+    return gl_config->size_x;
 }
 
 float map_get_size_y()
 {
-   return gl_config->size_y;
+    return gl_config->size_y;
 }
 
 int map_count_my_r4d2()
 {
-   return count_r4d2(glbPlayer->team_id);
+    return count_r4d2(glbPlayer->team_id);
 }
 
 float map_get_pulse(int team_id, float x, float y)
 {
-   if (!finitef(x) || !finitef(y))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   if (!is_visible(glbPlayer->team_id, x, y))
-   {
-      glbPlayer->error = NOT_VISIBLE;
-      return -1;
-   }
-   return get_pulse_team(x, y, team_id);
+    if ( !finitef(x) || !finitef(y))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    if ( !is_visible(glbPlayer->team_id, x, y))
+    {
+        glbPlayer->error = NOT_VISIBLE;
+        return -1;
+    }
+    return get_pulse_team(x, y, team_id);
 }
 
 float map_get_pulse_id(int akx_id, float x, float y)
 {
-   if (!finitef(x) || !finitef(y))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   if ((akx_id >= gl_config->nb_objects) || (akx_id < 0))
-   {
-      glbPlayer->error = NBR_OUT_OF_RANGE;
-      return -1;
-   }
-   if (!is_visible(glbPlayer->team_id, x, y))
-   {
-      glbPlayer->error = NOT_VISIBLE;
-      return -1;
-   }
-   if (glbObjects[akx_id].obj.type != obj_akx)
-   {
-      glbPlayer->error = TYPE_ERROR;
-      return -1;
-   }
-   return get_pulse_id(x, y, akx_id);
+    if ( !finitef(x) || !finitef(y))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    if (( akx_id >= gl_config->nb_objects ) || ( akx_id < 0 ))
+    {
+        glbPlayer->error = NBR_OUT_OF_RANGE;
+        return -1;
+    }
+    if ( !is_visible(glbPlayer->team_id, x, y))
+    {
+        glbPlayer->error = NOT_VISIBLE;
+        return -1;
+    }
+    if ( glbObjects[akx_id].obj.type != obj_akx )
+    {
+        glbPlayer->error = TYPE_ERROR;
+        return -1;
+    }
+    return get_pulse_id(x, y, akx_id);
 }
 
 static float __map_random_seed = 0.23;
 
 float map_random()
 {
-   __map_random_seed = 4 * __map_random_seed * (1 - __map_random_seed);
-   return __map_random_seed;
+    __map_random_seed = 4 * __map_random_seed * ( 1 - __map_random_seed );
+    return __map_random_seed;
 }
 
 void map_set_seed(float value)
 {
-   if (value < 0 || value > 1)
-   {
-      return;
-   }
-   __map_random_seed = value;
+    if ( value < 0 || value > 1 )
+    {
+        return;
+    }
+    __map_random_seed = value;
 }

+ 42 - 42
server/conf.c

@@ -5,51 +5,51 @@
 #include <conf.h>
 #include <ipc.h>
 
-#define	CONF_DEFAULT_PORT	    (4242)
-#define CONF_DEFAULT_MAP	    "./default.map"
-#define CONF_DEFAULT_NBTURNS	(420)
-#define CONF_DEFAULT_TURN_MSEC	(200)
-#define	DEF_TURN_TAKE_AKX	    (5)
-#define	DEF_TURN_UNTAKE_AKX	    (5)
-#define	DEF_TURN_TAKE_R4D2	    (5)
-#define	DEF_TURN_UNTAKE_R4D2	(5)
-#define	DEF_R4D2_SPEED		    (2.0F)
-#define	DEF_AKX_SPEED		    (0.1F)
-#define	DEF_PULSE_POWER		    (1000.0F)
-#define	DEF_SEE_POWER		    (1.0F)
-#define	DEF_PULSE_COEF		    (1.0F)
-#define	DEF_SIZE_X		        (1)
-#define	DEF_SIZE_Y		        (1)
-#define	DEF_DESTROY_SPEED	    (-1.0F)
+#define CONF_DEFAULT_PORT (4242)
+#define CONF_DEFAULT_MAP "./default.map"
+#define CONF_DEFAULT_NBTURNS (420)
+#define CONF_DEFAULT_TURN_MSEC (200)
+#define DEF_TURN_TAKE_AKX (5)
+#define DEF_TURN_UNTAKE_AKX (5)
+#define DEF_TURN_TAKE_R4D2 (5)
+#define DEF_TURN_UNTAKE_R4D2 (5)
+#define DEF_R4D2_SPEED (2.0F)
+#define DEF_AKX_SPEED (0.1F)
+#define DEF_PULSE_POWER (1000.0F)
+#define DEF_SEE_POWER (1.0F)
+#define DEF_PULSE_COEF (1.0F)
+#define DEF_SIZE_X (1)
+#define DEF_SIZE_Y (1)
+#define DEF_DESTROY_SPEED (-1.0F)
 
 conf_t *gl_config;
 
 conf_t *conf_set_default(conf_t *res)
 {
-   res->verbose = False;
-   res->quiet = False;
-   res->gfx = False;
-   res->map_name = CONF_DEFAULT_MAP;
-   res->nb_turns = CONF_DEFAULT_NBTURNS;
-   res->turn_msec = CONF_DEFAULT_TURN_MSEC;
-   res->turn_take_akx = DEF_TURN_TAKE_AKX;
-   res->turn_untake_akx = DEF_TURN_UNTAKE_AKX;
-   res->turn_take_r4d2 = DEF_TURN_TAKE_R4D2;
-   res->turn_untake_r4d2 = DEF_TURN_UNTAKE_R4D2;
-   res->r4d2_speed = DEF_R4D2_SPEED;
-   res->akx_speed = DEF_AKX_SPEED;
-   res->pulse_power = DEF_PULSE_POWER;
-   res->see_power = DEF_SEE_POWER;
-   res->destroy_speed = DEF_DESTROY_SPEED;
-   res->pulse_coef = DEF_PULSE_COEF;
-   res->nb_akx = res->nb_r4d2 = res->nb_objects = 0;
-   res->size_x = DEF_SIZE_X;
-   res->size_y = DEF_SIZE_Y;
-   res->players = NULL;
-   res->nb_players = 0;
-   res->turn_num = 0;
-   res->sand_file = NULL;
-   res->port = CONF_DEFAULT_PORT;
-   res->pub = True;
-   return res;
+    res->verbose = False;
+    res->quiet = False;
+    res->gfx = False;
+    res->map_name = CONF_DEFAULT_MAP;
+    res->nb_turns = CONF_DEFAULT_NBTURNS;
+    res->turn_msec = CONF_DEFAULT_TURN_MSEC;
+    res->turn_take_akx = DEF_TURN_TAKE_AKX;
+    res->turn_untake_akx = DEF_TURN_UNTAKE_AKX;
+    res->turn_take_r4d2 = DEF_TURN_TAKE_R4D2;
+    res->turn_untake_r4d2 = DEF_TURN_UNTAKE_R4D2;
+    res->r4d2_speed = DEF_R4D2_SPEED;
+    res->akx_speed = DEF_AKX_SPEED;
+    res->pulse_power = DEF_PULSE_POWER;
+    res->see_power = DEF_SEE_POWER;
+    res->destroy_speed = DEF_DESTROY_SPEED;
+    res->pulse_coef = DEF_PULSE_COEF;
+    res->nb_akx = res->nb_r4d2 = res->nb_objects = 0;
+    res->size_x = DEF_SIZE_X;
+    res->size_y = DEF_SIZE_Y;
+    res->players = NULL;
+    res->nb_players = 0;
+    res->turn_num = 0;
+    res->sand_file = NULL;
+    res->port = CONF_DEFAULT_PORT;
+    res->pub = True;
+    return res;
 }

+ 372 - 372
server/exec.c

@@ -17,449 +17,449 @@
 
 void calc_score()
 {
-   GSList *l;
-   player_t *player;
-
-   for (l = gl_config->players ; l != NULL ; l = l->next)
-   {
-      player = l->data;
-      player->score = count_akx(player->team_id) +
-                      count_r4d2(player->team_id) / ((float)gl_config->nb_r4d2);
-   }
+    GSList *l;
+    player_t *player;
+
+    for ( l = gl_config->players ; l != NULL ; l = l->next )
+    {
+        player = l->data;
+        player->score = count_akx(player->team_id) +
+                        count_r4d2(player->team_id) / ((float) gl_config->nb_r4d2 );
+    }
 }
 
 int get_max(int *nbr, int len)
 {
-   int max = nbr[0], team = 1;
-   int cpt;
-
-   for (cpt = 1 ; cpt < len ; cpt++)
-   {
-      if (nbr[cpt] > max)
-      {
-         max = nbr[cpt];
-         team = cpt + 1;
-      }
-      else
-      {
-         if (nbr[cpt] == max)
-         {
-            team = 0;
-         }
-      }
-   }
-   return team;
+    int max = nbr[0], team = 1;
+    int cpt;
+
+    for ( cpt = 1 ; cpt < len ; cpt++ )
+    {
+        if ( nbr[cpt] > max )
+        {
+            max = nbr[cpt];
+            team = cpt + 1;
+        }
+        else
+        {
+            if ( nbr[cpt] == max )
+            {
+                team = 0;
+            }
+        }
+    }
+    return team;
 }
 
 void check_conflict_akx(int akx_id)
 {
-   int *nbr_r4d2;
-   int cpt, winner;
-   item_t *temp;
-
-   nbr_r4d2 = malloc(gl_config->nb_players * sizeof(int));
-   bzero(nbr_r4d2, gl_config->nb_players * sizeof(int));
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      temp = glbObjects + cpt;
-      if (temp->obj.type == obj_r4d2)
-      {
-         if (temp->r4d2.action.type == act_r4d2_take_akx)
-         {
-            if (temp->r4d2.action.act.take_akx.target_id == akx_id)
+    int *nbr_r4d2;
+    int cpt, winner;
+    item_t *temp;
+
+    nbr_r4d2 = malloc(gl_config->nb_players * sizeof(int));
+    bzero(nbr_r4d2, gl_config->nb_players * sizeof(int));
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        temp = glbObjects + cpt;
+        if ( temp->obj.type == obj_r4d2 )
+        {
+            if ( temp->r4d2.action.type == act_r4d2_take_akx )
             {
-               nbr_r4d2[temp->r4d2.team_id - 1]++;
+                if ( temp->r4d2.action.act.take_akx.target_id == akx_id )
+                {
+                    nbr_r4d2[temp->r4d2.team_id - 1]++;
+                }
             }
-         }
-      }
-   }
-   winner = get_max(nbr_r4d2, gl_config->nb_players);
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      temp = glbObjects + cpt;
-      if (temp->obj.type == obj_r4d2)
-      {
-         if (temp->r4d2.action.type == act_r4d2_take_akx)
-         {
-            if (temp->r4d2.action.act.take_akx.target_id == akx_id)
+        }
+    }
+    winner = get_max(nbr_r4d2, gl_config->nb_players);
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        temp = glbObjects + cpt;
+        if ( temp->obj.type == obj_r4d2 )
+        {
+            if ( temp->r4d2.action.type == act_r4d2_take_akx )
             {
-               if (temp->r4d2.team_id != winner)
-               {
-                  set_default_action_r4d2(cpt);
-               }
+                if ( temp->r4d2.action.act.take_akx.target_id == akx_id )
+                {
+                    if ( temp->r4d2.team_id != winner )
+                    {
+                        set_default_action_r4d2(cpt);
+                    }
+                }
             }
-         }
-      }
-   }
-   free(nbr_r4d2);
+        }
+    }
+    free(nbr_r4d2);
 }
 
 void check_conflict_r4d2(int r4d2_id)
 {
-   int *nbr_r4d2;
-   int cpt, winner;
-   item_t *temp;
-
-   nbr_r4d2 = malloc(gl_config->nb_players * sizeof(int));
-   bzero(nbr_r4d2, gl_config->nb_players * sizeof(int));
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      temp = glbObjects + cpt;
-      if (temp->obj.type == obj_r4d2)
-      {
-         if (temp->r4d2.action.type == act_r4d2_take_r4d2)
-         {
-            if (temp->r4d2.action.act.take_r4d2.target_id == r4d2_id)
+    int *nbr_r4d2;
+    int cpt, winner;
+    item_t *temp;
+
+    nbr_r4d2 = malloc(gl_config->nb_players * sizeof(int));
+    bzero(nbr_r4d2, gl_config->nb_players * sizeof(int));
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        temp = glbObjects + cpt;
+        if ( temp->obj.type == obj_r4d2 )
+        {
+            if ( temp->r4d2.action.type == act_r4d2_take_r4d2 )
             {
-               nbr_r4d2[temp->r4d2.team_id - 1]++;
+                if ( temp->r4d2.action.act.take_r4d2.target_id == r4d2_id )
+                {
+                    nbr_r4d2[temp->r4d2.team_id - 1]++;
+                }
             }
-         }
-      }
-   }
-   winner = get_max(nbr_r4d2, gl_config->nb_players);
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      temp = glbObjects + cpt;
-      if (temp->obj.type == obj_r4d2)
-      {
-         if (temp->r4d2.action.type == act_r4d2_take_r4d2)
-         {
-            if (temp->r4d2.action.act.take_r4d2.target_id == r4d2_id)
+        }
+    }
+    winner = get_max(nbr_r4d2, gl_config->nb_players);
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        temp = glbObjects + cpt;
+        if ( temp->obj.type == obj_r4d2 )
+        {
+            if ( temp->r4d2.action.type == act_r4d2_take_r4d2 )
             {
-               if (temp->r4d2.team_id != winner)
-               {
-                  set_default_action_r4d2(cpt);
-               }
+                if ( temp->r4d2.action.act.take_r4d2.target_id == r4d2_id )
+                {
+                    if ( temp->r4d2.team_id != winner )
+                    {
+                        set_default_action_r4d2(cpt);
+                    }
+                }
             }
-         }
-      }
-   }
-   free(nbr_r4d2);
+        }
+    }
+    free(nbr_r4d2);
 }
 
 void check_conflict()
 {
-   int cpt;
-   item_t *temp;
-
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      temp = glbObjects + cpt;
-      if (temp->obj.type == obj_r4d2)
-      {
-         if (temp->r4d2.action.type == act_r4d2_take_akx)
-         {
-            check_conflict_akx(temp->r4d2.action.act.take_akx.target_id);
-         }
-         else if (temp->r4d2.action.type == act_r4d2_take_r4d2)
-         {
-            check_conflict_r4d2(temp->r4d2.action.act.take_r4d2.target_id);
-         }
-      }
-   }
+    int cpt;
+    item_t *temp;
+
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        temp = glbObjects + cpt;
+        if ( temp->obj.type == obj_r4d2 )
+        {
+            if ( temp->r4d2.action.type == act_r4d2_take_akx )
+            {
+                check_conflict_akx(temp->r4d2.action.act.take_akx.target_id);
+            }
+            else if ( temp->r4d2.action.type == act_r4d2_take_r4d2 )
+            {
+                check_conflict_r4d2(temp->r4d2.action.act.take_r4d2.target_id);
+            }
+        }
+    }
 }
 
 void exec_destroy(r4d2_t *r4d2)
 {
-   float speed;
-
-   speed = get_pulse_total(r4d2->x, r4d2->y, r4d2->team_id);
-   speed = gl_config->r4d2_speed + gl_config->pulse_coef * speed;
-
-   if (speed < 0)
-   {
-      if (speed <= gl_config->destroy_speed)
-      {
-         r4d2->change = True;
-         r4d2->team_id = 0;
-         set_default_action_r4d2(r4d2->id);
-      }
-   }
+    float speed;
+
+    speed = get_pulse_total(r4d2->x, r4d2->y, r4d2->team_id);
+    speed = gl_config->r4d2_speed + gl_config->pulse_coef * speed;
+
+    if ( speed < 0 )
+    {
+        if ( speed <= gl_config->destroy_speed )
+        {
+            r4d2->change = True;
+            r4d2->team_id = 0;
+            set_default_action_r4d2(r4d2->id);
+        }
+    }
 }
 
 void check_take()
 {
-   int cpt, tid;
-   item_t *it;
-
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      it = glbObjects + cpt;
-      if (it->obj.type == obj_r4d2)
-      {
-         switch (it->r4d2.action.type)
-         {
-         case act_r4d2_take_akx:
-            tid = it->r4d2.action.act.take_akx.target_id;
-            if (map_get_dist(glbObjects[cpt].r4d2.x,
-                             glbObjects[cpt].r4d2.y,
-                             glbObjects[tid].akx.x,
-                             glbObjects[tid].akx.y)
-                > DIST_MIN_TAKE)
-            {
-               set_default_action_r4d2(cpt);
-            }
-            break;
-         case act_r4d2_take_r4d2:
-            tid = it->r4d2.action.act.take_r4d2.target_id;
-            if (map_get_dist(glbObjects[cpt].r4d2.x,
-                             glbObjects[cpt].r4d2.y,
-                             glbObjects[tid].r4d2.x,
-                             glbObjects[tid].r4d2.y)
-                > DIST_MIN_TAKE)
+    int cpt, tid;
+    item_t *it;
+
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        it = glbObjects + cpt;
+        if ( it->obj.type == obj_r4d2 )
+        {
+            switch ( it->r4d2.action.type )
             {
-               set_default_action_r4d2(cpt);
+            case act_r4d2_take_akx:
+                tid = it->r4d2.action.act.take_akx.target_id;
+                if ( map_get_dist(glbObjects[cpt].r4d2.x,
+                                  glbObjects[cpt].r4d2.y,
+                                  glbObjects[tid].akx.x,
+                                  glbObjects[tid].akx.y)
+                     > DIST_MIN_TAKE )
+                {
+                    set_default_action_r4d2(cpt);
+                }
+                break;
+            case act_r4d2_take_r4d2:
+                tid = it->r4d2.action.act.take_r4d2.target_id;
+                if ( map_get_dist(glbObjects[cpt].r4d2.x,
+                                  glbObjects[cpt].r4d2.y,
+                                  glbObjects[tid].r4d2.x,
+                                  glbObjects[tid].r4d2.y)
+                     > DIST_MIN_TAKE )
+                {
+                    set_default_action_r4d2(cpt);
+                }
+                break;
+            default:
+                break;
             }
-            break;
-         default:
-            break;
-         }
-      }
-   }
+        }
+    }
 }
 
 void exec_objects()
 {
-   int cpt;
-
-   check_take();
-   check_conflict();
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      if (glbObjects[cpt].obj.type == obj_r4d2)
-      {
-         exec_destroy(&(glbObjects[cpt].r4d2));
-      }
-   }
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      if (glbObjects[cpt].obj.type == obj_akx)
-      {
-         if (glbObjects[cpt].akx.action.type == act_akx_move)
-         {
-            exec_akx_move(&(glbObjects[cpt].akx));
-         }
-      }
-      else if ((glbObjects[cpt].obj.type == obj_r4d2) &&
-               (glbObjects[cpt].r4d2.action.type == act_r4d2_move))
-      {
-         exec_r4d2_move(&(glbObjects[cpt].r4d2));
-      }
-   }
-   /* AJOUT MATHIAS */
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      if (glbObjects[cpt].obj.type == obj_akx)
-      {
-         exec_akx_reset_energy(&(glbObjects[cpt].akx));
-      }
-   }
-
-
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      if ((glbObjects[cpt].obj.type == obj_akx) &&
-          (glbObjects[cpt].akx.action.type == act_akx_link))
-      {
-         exec_akx_link(&(glbObjects[cpt].akx));
-      }
-   }
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      if (glbObjects[cpt].obj.type == obj_r4d2)
-      {
-         if (glbObjects[cpt].r4d2.action.type == act_r4d2_take_akx)
-         {
-            exec_r4d2_take_akx(&glbObjects[cpt].r4d2);
-         }
-         else if (glbObjects[cpt].r4d2.action.type == act_r4d2_take_r4d2)
-         {
-            exec_r4d2_take_r4d2(&glbObjects[cpt].r4d2);
-         }
-      }
-   }
-   for (cpt = 0 ; cpt < gl_config->nb_objects ; cpt++)
-   {
-      if ((glbObjects[cpt].obj.type == obj_akx) &&
-          (glbObjects[cpt].akx.action.type == act_akx_pulse))
-      {
-         exec_akx_pulse(&(glbObjects[cpt].akx));
-      }
-   }
-
-   calc_score();
-   gfx_client_new_turn(False);
+    int cpt;
+
+    check_take();
+    check_conflict();
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        if ( glbObjects[cpt].obj.type == obj_r4d2 )
+        {
+            exec_destroy(&( glbObjects[cpt].r4d2 ));
+        }
+    }
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        if ( glbObjects[cpt].obj.type == obj_akx )
+        {
+            if ( glbObjects[cpt].akx.action.type == act_akx_move )
+            {
+                exec_akx_move(&( glbObjects[cpt].akx ));
+            }
+        }
+        else if (( glbObjects[cpt].obj.type == obj_r4d2 ) &&
+                 ( glbObjects[cpt].r4d2.action.type == act_r4d2_move ))
+        {
+            exec_r4d2_move(&( glbObjects[cpt].r4d2 ));
+        }
+    }
+    /* AJOUT MATHIAS */
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        if ( glbObjects[cpt].obj.type == obj_akx )
+        {
+            exec_akx_reset_energy(&( glbObjects[cpt].akx ));
+        }
+    }
+
+
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        if (( glbObjects[cpt].obj.type == obj_akx ) &&
+            ( glbObjects[cpt].akx.action.type == act_akx_link ))
+        {
+            exec_akx_link(&( glbObjects[cpt].akx ));
+        }
+    }
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        if ( glbObjects[cpt].obj.type == obj_r4d2 )
+        {
+            if ( glbObjects[cpt].r4d2.action.type == act_r4d2_take_akx )
+            {
+                exec_r4d2_take_akx(&glbObjects[cpt].r4d2);
+            }
+            else if ( glbObjects[cpt].r4d2.action.type == act_r4d2_take_r4d2 )
+            {
+                exec_r4d2_take_r4d2(&glbObjects[cpt].r4d2);
+            }
+        }
+    }
+    for ( cpt = 0 ; cpt < gl_config->nb_objects ; cpt++ )
+    {
+        if (( glbObjects[cpt].obj.type == obj_akx ) &&
+            ( glbObjects[cpt].akx.action.type == act_akx_pulse ))
+        {
+            exec_akx_pulse(&( glbObjects[cpt].akx ));
+        }
+    }
+
+    calc_score();
+    gfx_client_new_turn(False);
 }
 
 void exec_r4d2_move(r4d2_t *r4d2)
 {
-   float diff_x, diff_y;
-   float signe_x, signe_y;
-   float prop_x, prop_y;
-   float speed;
-
-   speed = gl_config->r4d2_speed + gl_config->pulse_coef *
-                                   get_pulse_total(r4d2->x, r4d2->y, r4d2->team_id);
-   if (speed < 0)
-   {
-      speed = 0;
-   }
-   if (speed > (gl_config->r4d2_speed * 2))
-   {
-      speed = gl_config->r4d2_speed * 2;
-   }
-
-   diff_x = r4d2->action.act.move.x - r4d2->x;
-   diff_y = r4d2->action.act.move.y - r4d2->y;
-   signe_x = SIGNE(diff_x);
-   signe_y = SIGNE(diff_y);
-   if (signe_x || signe_y)
-   {
-      r4d2->change = True;
-      if (!signe_x || !signe_y)
-      {
-         r4d2->x += signe_x * speed;
-         r4d2->y += signe_y * speed;
-         diff_x = r4d2->action.act.move.x - r4d2->x;
-         diff_y = r4d2->action.act.move.y - r4d2->y;
-         if (signe_x != SIGNE(diff_x))
-         {
-            r4d2->x = r4d2->action.act.move.x;
-         }
-         if (signe_y != SIGNE(diff_y))
-         {
-            r4d2->y = r4d2->action.act.move.y;
-         }
-      }
-      else
-      {
-         prop_x = diff_x / sqrt(SQR(diff_x) + SQR(diff_y));
-         prop_y = diff_y / sqrt(SQR(diff_x) + SQR(diff_y));
-         r4d2->x += speed * prop_x;
-         r4d2->y += speed * prop_y;
-         diff_x = r4d2->action.act.move.x - r4d2->x;
-         diff_y = r4d2->action.act.move.y - r4d2->y;
-         if (signe_x != SIGNE(diff_x))
-         {
-            r4d2->x = r4d2->action.act.move.x;
-         }
-         if (signe_y != SIGNE(diff_y))
-         {
-            r4d2->y = r4d2->action.act.move.y;
-         }
-      }
-      r4d2->x = CLAMP(r4d2->x, 0, gl_config->size_x);
-      r4d2->y = CLAMP(r4d2->y, 0, gl_config->size_y);
-   }
+    float diff_x, diff_y;
+    float signe_x, signe_y;
+    float prop_x, prop_y;
+    float speed;
+
+    speed = gl_config->r4d2_speed + gl_config->pulse_coef *
+                                    get_pulse_total(r4d2->x, r4d2->y, r4d2->team_id);
+    if ( speed < 0 )
+    {
+        speed = 0;
+    }
+    if ( speed > ( gl_config->r4d2_speed * 2 ))
+    {
+        speed = gl_config->r4d2_speed * 2;
+    }
+
+    diff_x = r4d2->action.act.move.x - r4d2->x;
+    diff_y = r4d2->action.act.move.y - r4d2->y;
+    signe_x = SIGNE(diff_x);
+    signe_y = SIGNE(diff_y);
+    if ( signe_x || signe_y )
+    {
+        r4d2->change = True;
+        if ( !signe_x || !signe_y )
+        {
+            r4d2->x += signe_x * speed;
+            r4d2->y += signe_y * speed;
+            diff_x = r4d2->action.act.move.x - r4d2->x;
+            diff_y = r4d2->action.act.move.y - r4d2->y;
+            if ( signe_x != SIGNE(diff_x))
+            {
+                r4d2->x = r4d2->action.act.move.x;
+            }
+            if ( signe_y != SIGNE(diff_y))
+            {
+                r4d2->y = r4d2->action.act.move.y;
+            }
+        }
+        else
+        {
+            prop_x = diff_x / sqrt(SQR(diff_x) + SQR(diff_y));
+            prop_y = diff_y / sqrt(SQR(diff_x) + SQR(diff_y));
+            r4d2->x += speed * prop_x;
+            r4d2->y += speed * prop_y;
+            diff_x = r4d2->action.act.move.x - r4d2->x;
+            diff_y = r4d2->action.act.move.y - r4d2->y;
+            if ( signe_x != SIGNE(diff_x))
+            {
+                r4d2->x = r4d2->action.act.move.x;
+            }
+            if ( signe_y != SIGNE(diff_y))
+            {
+                r4d2->y = r4d2->action.act.move.y;
+            }
+        }
+        r4d2->x = CLAMP(r4d2->x, 0, gl_config->size_x);
+        r4d2->y = CLAMP(r4d2->y, 0, gl_config->size_y);
+    }
 }
 
 void exec_akx_move(akx_t *akx)
 {
-   float diff_x, diff_y;
-   float signe_x, signe_y;
-   float prop_x, prop_y;
-
-   diff_x = akx->action.act.move.x - akx->x;
-   diff_y = akx->action.act.move.y - akx->y;
-   signe_x = SIGNE(diff_x);
-   signe_y = SIGNE(diff_y);
-   if (signe_x || signe_y)
-   {
-      akx->change = True;
-      if (!signe_x || !signe_y)
-      {
-         akx->x += signe_x * gl_config->akx_speed;
-         akx->y += signe_y * gl_config->akx_speed;
-         diff_x = akx->action.act.move.x - akx->x;
-         diff_y = akx->action.act.move.y - akx->y;
-         if (signe_x != SIGNE(diff_x))
-         {
-            akx->x = akx->action.act.move.x;
-         }
-         if (signe_y != SIGNE(diff_y))
-         {
-            akx->y = akx->action.act.move.y;
-         }
-      }
-      else
-      {
-         prop_x = diff_x / sqrt(SQR(diff_x) + SQR(diff_y));
-         prop_y = diff_y / sqrt(SQR(diff_x) + SQR(diff_y));
-         akx->x += gl_config->akx_speed * prop_x;
-         akx->y += gl_config->akx_speed * prop_y;
-         diff_x = akx->action.act.move.x - akx->x;
-         diff_y = akx->action.act.move.y - akx->y;
-         if (signe_x != SIGNE(diff_x))
-         {
-            akx->x = akx->action.act.move.x;
-         }
-         if (signe_y != SIGNE(diff_y))
-         {
-            akx->y = akx->action.act.move.y;
-         }
-      }
-      akx->x = CLAMP(akx->x, 0, gl_config->size_x);
-      akx->y = CLAMP(akx->y, 0, gl_config->size_y);
-   }
+    float diff_x, diff_y;
+    float signe_x, signe_y;
+    float prop_x, prop_y;
+
+    diff_x = akx->action.act.move.x - akx->x;
+    diff_y = akx->action.act.move.y - akx->y;
+    signe_x = SIGNE(diff_x);
+    signe_y = SIGNE(diff_y);
+    if ( signe_x || signe_y )
+    {
+        akx->change = True;
+        if ( !signe_x || !signe_y )
+        {
+            akx->x += signe_x * gl_config->akx_speed;
+            akx->y += signe_y * gl_config->akx_speed;
+            diff_x = akx->action.act.move.x - akx->x;
+            diff_y = akx->action.act.move.y - akx->y;
+            if ( signe_x != SIGNE(diff_x))
+            {
+                akx->x = akx->action.act.move.x;
+            }
+            if ( signe_y != SIGNE(diff_y))
+            {
+                akx->y = akx->action.act.move.y;
+            }
+        }
+        else
+        {
+            prop_x = diff_x / sqrt(SQR(diff_x) + SQR(diff_y));
+            prop_y = diff_y / sqrt(SQR(diff_x) + SQR(diff_y));
+            akx->x += gl_config->akx_speed * prop_x;
+            akx->y += gl_config->akx_speed * prop_y;
+            diff_x = akx->action.act.move.x - akx->x;
+            diff_y = akx->action.act.move.y - akx->y;
+            if ( signe_x != SIGNE(diff_x))
+            {
+                akx->x = akx->action.act.move.x;
+            }
+            if ( signe_y != SIGNE(diff_y))
+            {
+                akx->y = akx->action.act.move.y;
+            }
+        }
+        akx->x = CLAMP(akx->x, 0, gl_config->size_x);
+        akx->y = CLAMP(akx->y, 0, gl_config->size_y);
+    }
 }
 
 void exec_r4d2_take_r4d2(r4d2_t *r4d2)
 {
-   r4d2->action.act.take_r4d2.turn_need--;
-   if (r4d2->action.act.take_r4d2.turn_need <= 0)
-   {
-      glbObjects[r4d2->action.act.take_r4d2.target_id].obj.change = True;
-      glbObjects[r4d2->action.act.take_r4d2.target_id].obj.team_id = r4d2->team_id;
-      r4d2->action.type = act_r4d2_move;
-      r4d2->action.act.move.x = r4d2->x;
-      r4d2->action.act.move.y = r4d2->y;
-   }
+    r4d2->action.act.take_r4d2.turn_need--;
+    if ( r4d2->action.act.take_r4d2.turn_need <= 0 )
+    {
+        glbObjects[r4d2->action.act.take_r4d2.target_id].obj.change = True;
+        glbObjects[r4d2->action.act.take_r4d2.target_id].obj.team_id = r4d2->team_id;
+        r4d2->action.type = act_r4d2_move;
+        r4d2->action.act.move.x = r4d2->x;
+        r4d2->action.act.move.y = r4d2->y;
+    }
 }
 
 void exec_r4d2_take_akx(r4d2_t *r4d2)
 {
-   r4d2->action.act.take_akx.turn_need--;
-   if (r4d2->action.act.take_akx.turn_need <= 0)
-   {
-      glbObjects[r4d2->action.act.take_akx.target_id].obj.change = True;
-      glbObjects[r4d2->action.act.take_akx.target_id].obj.team_id = r4d2->team_id;
-      r4d2->action.type = act_r4d2_move;
-      r4d2->action.act.move.x = r4d2->x;
-      r4d2->action.act.move.y = r4d2->y;
-   }
+    r4d2->action.act.take_akx.turn_need--;
+    if ( r4d2->action.act.take_akx.turn_need <= 0 )
+    {
+        glbObjects[r4d2->action.act.take_akx.target_id].obj.change = True;
+        glbObjects[r4d2->action.act.take_akx.target_id].obj.team_id = r4d2->team_id;
+        r4d2->action.type = act_r4d2_move;
+        r4d2->action.act.move.x = r4d2->x;
+        r4d2->action.act.move.y = r4d2->y;
+    }
 }
 
 void exec_akx_pulse(akx_t *akx)
 {
-   akx->action.act.pulse.x = akx->action.act.pulse.new_x;
-   akx->action.act.pulse.y = akx->action.act.pulse.new_y;
-   akx->action.act.pulse.angle = akx->action.act.pulse.new_angle;
+    akx->action.act.pulse.x = akx->action.act.pulse.new_x;
+    akx->action.act.pulse.y = akx->action.act.pulse.new_y;
+    akx->action.act.pulse.angle = akx->action.act.pulse.new_angle;
 
-   /* VIRE PAR MATHIAS akx->energy = gl_config->pulse_power; */
+    /* VIRE PAR MATHIAS akx->energy = gl_config->pulse_power; */
 }
 
 /* AJOUT MATHIAS */
 void exec_akx_reset_energy(akx_t *akx)
 {
-   akx->energy = gl_config->pulse_power;
+    akx->energy = gl_config->pulse_power;
 }
 
 void exec_akx_link(akx_t *akx)
 {
-   float dst;
+    float dst;
 
-   if (akx->team_id != glbObjects[akx->action.act.link.target_id].obj.team_id)
-   {
-      glbObjects[akx->id].obj.change = True;
-      set_default_action_akx(akx->id);
-      return;
-   }
+    if ( akx->team_id != glbObjects[akx->action.act.link.target_id].obj.team_id )
+    {
+        glbObjects[akx->id].obj.change = True;
+        set_default_action_akx(akx->id);
+        return;
+    }
 
-   dst = map_get_dist(akx->x, akx->y, glbObjects[akx->action.act.link.target_id].obj.x,
-                      glbObjects[akx->action.act.link.target_id].obj.y);
+    dst = map_get_dist(akx->x, akx->y, glbObjects[akx->action.act.link.target_id].obj.x,
+                       glbObjects[akx->action.act.link.target_id].obj.y);
 
-   glbObjects[akx->action.act.link.target_id].akx.energy += akx->energy / (1 + sqrt(dst));
+    glbObjects[akx->action.act.link.target_id].akx.energy += akx->energy / ( 1 + sqrt(dst));
 
-   akx->energy = gl_config->pulse_power;
+    akx->energy = gl_config->pulse_power;
 }
 

+ 153 - 155
server/game.c

@@ -1,5 +1,3 @@
-/* $Id: game.c,v 1.60 2001/05/07 02:41:36 kilobug Exp $ */
-
 #include <stdio.h>
 #include <math.h>
 #include <signal.h>
@@ -26,186 +24,186 @@ static void signal_usr1(int foo)
 
 static void client_died(int foo)
 {
-   glbPlayer->alive = False;
-   printf("%d: died.\n", glbPlayer->team_id);
-   fflush(stdout);
-   wait(NULL);
+    glbPlayer->alive = False;
+    printf("%d: died.\n", glbPlayer->team_id);
+    fflush(stdout);
+    wait(NULL);
 }
 
 static void play_turn(int turn_num)
 {
-   int i;
-
-   start_timer();
-   if (glbPlayer->new)
-   {
-      player_init(glbPlayer, glbPlayer->team_id);
-      glbPlayer->new = False;
-   }
-   else
-   {
-      player_new_turn(glbPlayer, turn_num);
-
-      for (i = 0 ; i < gl_config->nb_objects ; i++)
-      {
-         if (glbObjects[i].obj.team_id == glbPlayer->team_id)
-         {
-            switch (glbObjects[i].obj.type)
+    int i;
+
+    start_timer();
+    if ( glbPlayer->new )
+    {
+        player_init(glbPlayer, glbPlayer->team_id);
+        glbPlayer->new = False;
+    }
+    else
+    {
+        player_new_turn(glbPlayer, turn_num);
+
+        for ( i = 0 ; i < gl_config->nb_objects ; i++ )
+        {
+            if ( glbObjects[i].obj.team_id == glbPlayer->team_id )
             {
-            case obj_akx:
-               player_turn_akx(glbPlayer, glbObjects[i].obj.id);
-               break;
-            case obj_r4d2:
-               player_turn_r4d2(glbPlayer, glbObjects[i].obj.id);
-               break;
+                switch ( glbObjects[i].obj.type )
+                {
+                case obj_akx:
+                    player_turn_akx(glbPlayer, glbObjects[i].obj.id);
+                    break;
+                case obj_r4d2:
+                    player_turn_r4d2(glbPlayer, glbObjects[i].obj.id);
+                    break;
+                }
             }
-         }
-      }
-   }
-   stop_timer();
-   fflush(stdout);
-   kill(getppid(), SIGUSR1);
-   sigsuspend(gl_config->mask);
+        }
+    }
+    stop_timer();
+    fflush(stdout);
+    kill(getppid(), SIGUSR1);
+    sigsuspend(gl_config->mask);
 }
 
 void start_client(player_t *player, int turn_num)
 {
-   pid_t pid;
-   struct rlimit rl;
-
-   player->alive = True;
-   signal(SIGUSR1, signal_usr1);
-   if (gl_config->gfx)
-   {
-      fflush(gl_config->gfx_clients->wmaster);
-   }
-   if ((pid = fork()))
-   {
-      player->pid = pid;
-   }
-   else
-   {
-      close(1);
-      if (gl_config->gfx)
-      {
-         fclose(gl_config->gfx_clients->wmaster);
-         gl_config->gfx_clients->wmaster = NULL;
-         gl_config->gfx_clients->master = -1;
-         close(gl_config->gfx_clients->sock);
-         gl_config->gfx_clients->sock = -1;
-      }
-      dup2(player->pipe_write, 1);
-      close(player->pipe_write);
-      close(player->pipe_read);
-      player->new = True;
-      glbPlayer = player;
-      rl.rlim_cur = rl.rlim_max = 16 * 1024 * 1024;
-      setrlimit(RLIMIT_DATA, &rl);
-      while (True)
-      {
-         play_turn(turn_num++);
-      }
-   }
-   printf("Client %d : pid = %d\n", player->team_id, pid);
-   fflush(stdout);
+    pid_t pid;
+    struct rlimit rl;
+
+    player->alive = True;
+    signal(SIGUSR1, signal_usr1);
+    if ( gl_config->gfx )
+    {
+        fflush(gl_config->gfx_clients->wmaster);
+    }
+    if (( pid = fork()))
+    {
+        player->pid = pid;
+    }
+    else
+    {
+        close(1);
+        if ( gl_config->gfx )
+        {
+            fclose(gl_config->gfx_clients->wmaster);
+            gl_config->gfx_clients->wmaster = NULL;
+            gl_config->gfx_clients->master = -1;
+            close(gl_config->gfx_clients->sock);
+            gl_config->gfx_clients->sock = -1;
+        }
+        dup2(player->pipe_write, 1);
+        close(player->pipe_write);
+        close(player->pipe_read);
+        player->new = True;
+        glbPlayer = player;
+        rl.rlim_cur = rl.rlim_max = 16 * 1024 * 1024;
+        setrlimit(RLIMIT_DATA, &rl);
+        while ( True)
+        {
+            play_turn(turn_num++);
+        }
+    }
+    printf("Client %d : pid = %d\n", player->team_id, pid);
+    fflush(stdout);
 }
 
 void turn_client(player_t *play)
 {
-   if (play->alive)
-   {
-      kill(play->pid, SIGUSR1);
-      sigsuspend(gl_config->mask);
-   }
-   else
-   {
-      start_client(glbPlayer, gl_config->turn_num);
-   }
+    if ( play->alive )
+    {
+        kill(play->pid, SIGUSR1);
+        sigsuspend(gl_config->mask);
+    }
+    else
+    {
+        start_client(glbPlayer, gl_config->turn_num);
+    }
 }
 
 void genere_pipe()
 {
-   GSList *l;
-   player_t *player;
-   int fds[2];
-
-   for (l = gl_config->players ; l != NULL ; l = l->next)
-   {
-      pipe(fds);
-      player = l->data;
-      player->pipe_read = fds[0];
-      player->pipe_write = fds[1];
-   }
+    GSList *l;
+    player_t *player;
+    int fds[2];
+
+    for ( l = gl_config->players ; l != NULL ; l = l->next )
+    {
+        pipe(fds);
+        player = l->data;
+        player->pipe_read = fds[0];
+        player->pipe_write = fds[1];
+    }
 }
 
 int check_done()
 {
-   return (map_count_r4d2() == count_r4d2(0));
+    return ( map_count_r4d2() == count_r4d2(0));
 }
 
 /* lanceur de partie */
 void game_launch(conf_t *conf)
 {
-   GSList *l;
-   int i;
-   int fds[2];
-   int pid;
-
-   genere_pipe();
-   signal(SIGCHLD, client_died);
-   if (pipe(fds) == -1)
-   {
-      perror("pipe");
-      exit(1);
-   }
-   fflush(stdout);
-   if ((pid = fork()) == 0)
-   {
-      close(0);
-      dup2(fds[0], 0);
-      close(fds[0]);
-      close(fds[1]);
-      launch_messager();
-   }
-   else
-   {
-      /*fclose(stdout);*/
-      dup2(fds[1], 1);
-      close(fds[1]);
-      close(fds[0]);
-      /*stdout = fdopen(1, "w");*/
-      printf("Messager : pid = %d\n", pid);
-      printf("Serveur : pid = %d\n", getpid());
-      fflush(stdout);
-      gl_config->messager_pid = pid;
-
-      for (conf->turn_num = 0 ; conf->turn_num <= conf->nb_turns ; conf->turn_num++)
-      {
-         printf("Tour n %d sur %d\n", conf->turn_num, conf->nb_turns);
-         fflush(stdout);
-
-         for (i = 0 ; i < conf->nb_objects ; i++)
-         {
-            glbObjects[i].obj.change = False;
-         }
-
-         for (l = conf->players ; l != NULL ; l = l->next)
-         {
-            glbPlayer = l->data;
-            turn_client(l->data);
-         }
-
-         if (conf->turn_num != 0)
-         {
-            exec_objects();
-         }
-
-         if (check_done())
-         {
-            break;
-         }
-      }
-   }
+    GSList *l;
+    int i;
+    int fds[2];
+    int pid;
+
+    genere_pipe();
+    signal(SIGCHLD, client_died);
+    if ( pipe(fds) == -1 )
+    {
+        perror("pipe");
+        exit(1);
+    }
+    fflush(stdout);
+    if (( pid = fork()) == 0 )
+    {
+        close(0);
+        dup2(fds[0], 0);
+        close(fds[0]);
+        close(fds[1]);
+        launch_messager();
+    }
+    else
+    {
+        /*fclose(stdout);*/
+        dup2(fds[1], 1);
+        close(fds[1]);
+        close(fds[0]);
+        /*stdout = fdopen(1, "w");*/
+        printf("Messager : pid = %d\n", pid);
+        printf("Serveur : pid = %d\n", getpid());
+        fflush(stdout);
+        gl_config->messager_pid = pid;
+
+        for ( conf->turn_num = 0 ; conf->turn_num <= conf->nb_turns ; conf->turn_num++ )
+        {
+            printf("Tour n %d sur %d\n", conf->turn_num, conf->nb_turns);
+            fflush(stdout);
+
+            for ( i = 0 ; i < conf->nb_objects ; i++ )
+            {
+                glbObjects[i].obj.change = False;
+            }
+
+            for ( l = conf->players ; l != NULL ; l = l->next )
+            {
+                glbPlayer = l->data;
+                turn_client(l->data);
+            }
+
+            if ( conf->turn_num != 0 )
+            {
+                exec_objects();
+            }
+
+            if ( check_done())
+            {
+                break;
+            }
+        }
+    }
 }
 
 

+ 0 - 2
server/include/action.h

@@ -1,5 +1,3 @@
-/* $Id: action.h,v 1.7 2001/04/26 17:57:08 glop Exp $ */
-
 #ifndef __PROLO_ACTION_H__
 #define __PROLO_ACTION_H__
 

+ 2 - 2
server/include/client.h

@@ -1,12 +1,12 @@
-/* $Id: client.h,v 1.4 2001/04/06 17:15:50 glop Exp $ */
-
 #ifndef __PROLO_CLIENT_H__
 #define __PROLO_CLIENT_H__
 
 void set_default_action_r4d2(int r4d2_id);
+
 void set_default_action_akx(int akx_id);
 
 int count_akx(int team_id);
+
 int count_r4d2(int team_id);
 
 #endif

+ 31 - 33
server/include/conf.h

@@ -1,5 +1,3 @@
-/* $Id: conf.h,v 1.26 2001/05/03 17:18:04 kilobug Exp $ */
-
 #ifndef __PROLO_CONF_H__
 #define __PROLO_CONF_H__
 
@@ -10,37 +8,37 @@
 
 typedef struct _conf_t
 {
-  int		nb_turns;
-  boolean_t	verbose;
-  boolean_t	quiet;
-  boolean_t	gfx, pub;
-  gfx_t		*gfx_clients;
-  const char	*map_name;
-  GSList	*players;
-  int		nb_objects;
-  int		turn_num;
-  pid_t		messager_pid;
-  int		port;
-
-  int		nb_akx;
-  int		nb_r4d2;
-  int		turn_msec;
-  int		nb_players;
-
-  int		turn_take_akx;
-  int		turn_untake_akx;
-  int		turn_take_r4d2;
-  int		turn_untake_r4d2;
-  float		r4d2_speed;
-  float		akx_speed;
-  float		pulse_power;
-  float		see_power;
-  float		pulse_coef;
-  float		destroy_speed;
-  float		size_x;
-  float		size_y;
-  char		*sand_file;
-  sigset_t	*mask;
+    int nb_turns;
+    boolean_t verbose;
+    boolean_t quiet;
+    boolean_t gfx, pub;
+    gfx_t *gfx_clients;
+    const char *map_name;
+    GSList *players;
+    int nb_objects;
+    int turn_num;
+    pid_t messager_pid;
+    int port;
+
+    int nb_akx;
+    int nb_r4d2;
+    int turn_msec;
+    int nb_players;
+
+    int turn_take_akx;
+    int turn_untake_akx;
+    int turn_take_r4d2;
+    int turn_untake_r4d2;
+    float r4d2_speed;
+    float akx_speed;
+    float pulse_power;
+    float see_power;
+    float pulse_coef;
+    float destroy_speed;
+    float size_x;
+    float size_y;
+    char *sand_file;
+    sigset_t *mask;
 } conf_t;
 
 extern conf_t *gl_config;

+ 8 - 10
server/include/erreur.h

@@ -1,15 +1,13 @@
-/* $Id: erreur.h,v 1.3 2001/04/25 15:20:20 glop Exp $ */
-
 #ifndef __PROLO_ERREUR_H__
 #define __PROLO_ERREUR_H__
 
-#define	NONE			0
-#define NOT_YOURS		1
-#define	NOT_VISIBLE		2
-#define NBR_OUT_OF_RANGE	3
-#define	POS_OUT_OF_RANGE	4
-#define	TYPE_ERROR		5
-#define	INVALID_TARGET		6
-#define	DESTROYED		7
+#define    NONE            0
+#define NOT_YOURS        1
+#define    NOT_VISIBLE        2
+#define NBR_OUT_OF_RANGE    3
+#define    POS_OUT_OF_RANGE    4
+#define    TYPE_ERROR        5
+#define    INVALID_TARGET        6
+#define    DESTROYED        7
 
 #endif

+ 13 - 13
server/include/exec.h

@@ -1,12 +1,10 @@
-/* $Id: exec.h,v 1.12 2001/05/06 18:24:26 kilobug Exp $ */
-
 #ifndef __PROLO_EXEC_H__
 #define __PROLO_EXEC_H__
 
-#define	SIGNE(_x)	(((_x) > 0) ? (1) : (((_x) < 0) ? (-1) : (0)))
-#define	SQR(_x)		((_x) * (_x))
+#define    SIGNE(_x)    (((_x) > 0) ? (1) : (((_x) < 0) ? (-1) : (0)))
+#define    SQR(_x)        ((_x) * (_x))
 #ifndef MAXFLOAT
-#define MAXFLOAT	(3.40282347e+38F)
+#define MAXFLOAT    (3.40282347e+38F)
 #endif
 
 #define CLAMP(_v, _min, _max) ((_v < _min)?_min:((_v > _max)?_max:_v))
@@ -19,19 +17,21 @@
   4 - Take
  */
 
-void	exec_r4d2_move(r4d2_t *r4d2);
-void	exec_akx_move(akx_t *akx);
+void exec_r4d2_move(r4d2_t *r4d2);
+
+void exec_akx_move(akx_t *akx);
+
+void exec_r4d2_take_akx(r4d2_t *r4d2);
 
-void	exec_r4d2_take_akx(r4d2_t *r4d2);
-void	exec_r4d2_take_r4d2(r4d2_t *r4d2);
+void exec_r4d2_take_r4d2(r4d2_t *r4d2);
 
-void	exec_akx_pulse(akx_t *akx);
+void exec_akx_pulse(akx_t *akx);
 
 /* AJOUTE par MATHIAS */
-void    exec_akx_reset_energy(akx_t *akx);
+void exec_akx_reset_energy(akx_t *akx);
 
-void	exec_akx_link(akx_t *akx);
+void exec_akx_link(akx_t *akx);
 
-void	exec_objects();
+void exec_objects();
 
 #endif

+ 1 - 2
server/include/game.h

@@ -1,5 +1,3 @@
-#/* $Id: game.h,v 1.2 2001/05/02 11:32:08 glop Exp $ */
-
 #ifndef __PROLO_GAME_H__
 #define __PROLO_GAME_H__
 
@@ -7,6 +5,7 @@
 #include "player.h"
 
 void game_launch(conf_t *conf);
+
 void start_client(player_t *player, int turn_num);
 
 #endif

+ 4 - 2
server/include/ipc.h

@@ -1,12 +1,14 @@
-/* $Id: ipc.h,v 1.6 2001/04/29 22:07:44 kilobug Exp $ */
-
 #ifndef __PROLO_IPC_H__
 #define __PROLO_IPC_H__
 
 int get_shm_conf_id();
+
 int get_shm_world_id();
+
 int get_shm_plr_id();
+
 void *shm_alloc(int size, int id);
+
 void clean_shm();
 
 #endif

+ 1 - 3
server/include/message.h

@@ -1,10 +1,8 @@
-/* $Id: message.h,v 1.1 2001/04/06 20:14:21 glop Exp $ */
-
 #ifndef __PROLO_MESSAGE_H__
 #define __PROLO_MESSAGE_H__
 
 void launch_messager();
 
-#define	MESSAGE_BUFFER_SIZE	256
+#define    MESSAGE_BUFFER_SIZE    256
 
 #endif

+ 1 - 3
server/include/network.h

@@ -1,5 +1,3 @@
-/* $Id: network.h,v 1.6 2001/04/15 14:57:19 kilobug Exp $ */
-
 #ifndef __PROLO_SERVER_NETWORK_H__
 #define __PROLO_SERVER_NETWORK_H__
 
@@ -19,7 +17,7 @@ typedef struct _gfx_t
     int sock;
     int master;
     FILE *wmaster;
-    GSList *clients;
+    //GSList *clients;
 } gfx_t;
 
 boolean_t gfx_get_ack(gfx_client_t *cl);

+ 1 - 2
server/include/objects.h

@@ -1,5 +1,3 @@
-/* $Id: private.h,v 1.17 2001/05/07 02:41:36 kilobug Exp $ */
-
 #ifndef __PROLO_PRIVATE_H__
 #define __PROLO_PRIVATE_H__
 
@@ -62,6 +60,7 @@ typedef union _item_t
 extern item_t *glbObjects;
 
 void new_akx(float x, float y, int id);
+
 void new_r4d2(float x, float y, int id);
 
 #endif

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff