summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x]src/Makefile223
-rwxr-xr-xsrc/Makefile-listserver27
-rw-r--r--[-rwxr-xr-x]src/Makefile-nosound197
-rwxr-xr-xsrc/Makefile-publicServer106
-rw-r--r--src/Makefile-sdlnet29
-rw-r--r--src/Makefile-server26
-rw-r--r--src/audio/Makefile17
-rw-r--r--src/audio/audio.c (renamed from src/audio.c)6
-rw-r--r--src/audio/audio.h12
-rw-r--r--src/audio/music.c (renamed from src/music.c)16
-rw-r--r--src/audio/music.h36
-rw-r--r--src/audio/sound.c (renamed from src/sound.c)16
-rw-r--r--src/audio/sound.h33
-rw-r--r--src/base/Makefile67
-rw-r--r--src/base/arena.c (renamed from src/arena.c)20
-rw-r--r--src/base/arena.h43
-rw-r--r--src/base/arenaFile.c (renamed from src/arenaFile.c)81
-rw-r--r--src/base/arenaFile.h22
-rw-r--r--src/base/bool.h13
-rw-r--r--src/base/checkFront.c (renamed from src/checkFront.c)12
-rw-r--r--src/base/checkFront.h22
-rwxr-xr-xsrc/base/director.c (renamed from src/director.c)6
-rw-r--r--src/base/director.h18
-rw-r--r--src/base/fake_audio.c (renamed from src/fake_audio.c)4
-rw-r--r--src/base/gun.c (renamed from src/gun.c)45
-rw-r--r--src/base/gun.h21
-rwxr-xr-xsrc/base/homeDirector.c (renamed from src/homeDirector.c)6
-rwxr-xr-xsrc/base/homeDirector.h13
-rw-r--r--src/base/idManager.c (renamed from src/idManager.c)6
-rw-r--r--src/base/idManager.h19
-rw-r--r--src/base/item.c (renamed from src/item.c)48
-rw-r--r--src/base/item.h79
-rwxr-xr-xsrc/base/list.c (renamed from src/list.c)4
-rwxr-xr-xsrc/base/list.h33
-rw-r--r--src/base/main.c (renamed from src/main.c)13
-rw-r--r--src/base/main.h33
-rwxr-xr-xsrc/base/modules.c (renamed from src/modules.c)27
-rw-r--r--src/base/modules.h78
-rw-r--r--src/base/myTimer.c (renamed from src/myTimer.c)9
-rw-r--r--src/base/myTimer.h32
-rw-r--r--src/base/net_multiplayer.c (renamed from src/net_multiplayer.c)36
-rw-r--r--src/base/net_multiplayer.h35
-rw-r--r--src/base/path.h33
-rw-r--r--src/base/protect.c (renamed from src/protect.c)6
-rw-r--r--src/base/protect.h30
-rw-r--r--src/base/proto.c (renamed from src/proto.c)45
-rw-r--r--src/base/proto.h81
-rw-r--r--src/base/server.c (renamed from src/server.c)32
-rw-r--r--src/base/server.h93
-rw-r--r--src/base/shot.c (renamed from src/shot.c)20
-rw-r--r--src/base/shot.h61
-rw-r--r--src/base/space.c (renamed from src/space.c)0
-rw-r--r--src/base/space.h38
-rw-r--r--src/base/storage.c (renamed from src/storage.c)0
-rw-r--r--src/base/storage.h16
-rw-r--r--src/base/string_length.h16
-rwxr-xr-xsrc/base/textFile.c (renamed from src/textFile.c)5
-rwxr-xr-xsrc/base/textFile.h21
-rw-r--r--src/base/tux.c (renamed from src/tux.c)51
-rw-r--r--src/base/tux.h137
-rwxr-xr-xsrc/buffer.c121
-rw-r--r--src/client/Makefile36
-rw-r--r--src/client/client.c (renamed from src/client.c)25
-rw-r--r--src/client/client.h35
-rw-r--r--src/client/configFile.c (renamed from src/configFile.c)4
-rw-r--r--src/client/configFile.h20
-rwxr-xr-xsrc/client/font.c (renamed from src/font.c)8
-rwxr-xr-xsrc/client/font.h26
-rw-r--r--src/client/game.c (renamed from src/game.c)59
-rw-r--r--src/client/game.h9
-rwxr-xr-xsrc/client/image.c (renamed from src/image.c)13
-rwxr-xr-xsrc/client/image.h35
-rwxr-xr-xsrc/client/interface.c (renamed from src/interface.c)8
-rwxr-xr-xsrc/client/interface.h40
-rw-r--r--src/client/keytable.c (renamed from src/keytable.c)13
-rw-r--r--src/client/keytable.h27
-rw-r--r--src/client/language.c (renamed from src/language.c)14
-rw-r--r--src/client/language.h12
-rwxr-xr-xsrc/client/layer.c (renamed from src/layer.c)16
-rwxr-xr-xsrc/client/layer.h53
-rw-r--r--src/client/panel.c (renamed from src/panel.c)16
-rw-r--r--src/client/panel.h27
-rw-r--r--src/client/screen.c (renamed from src/screen.c)11
-rw-r--r--src/client/screen.h32
-rw-r--r--src/client/term.c (renamed from src/term.c)13
-rw-r--r--src/client/term.h17
-rw-r--r--src/hashTable.c221
-rw-r--r--src/listServer.c277
-rwxr-xr-xsrc/modules/Makefile22
-rwxr-xr-xsrc/modules/modAI.c256
-rwxr-xr-xsrc/modules/modPipe.c453
-rwxr-xr-xsrc/modules/modTeleport.c506
-rwxr-xr-xsrc/modules/modWall.c331
-rw-r--r--src/net_sdl/Makefile9
-rw-r--r--src/net_sdl/sdl_udp.c (renamed from src/sdl_udp.c)4
-rw-r--r--src/net_sdl/sdl_udp.h28
-rw-r--r--src/net_unix/Makefile9
-rw-r--r--src/net_unix/udp.c (renamed from src/udp.c)8
-rw-r--r--src/net_unix/udp.h31
-rwxr-xr-xsrc/network.c101
-rw-r--r--src/screen/Makefile29
-rw-r--r--src/screen/screen_analyze.c (renamed from src/screen_analyze.c)32
-rw-r--r--src/screen/screen_analyze.h25
-rw-r--r--src/screen/screen_choiceArena.c (renamed from src/screen_choiceArena.c)39
-rw-r--r--src/screen/screen_choiceArena.h17
-rw-r--r--src/screen/screen_credits.c (renamed from src/screen_credits.c)34
-rw-r--r--src/screen/screen_credits.h20
-rw-r--r--src/screen/screen_gameType.c (renamed from src/screen_gameType.c)44
-rw-r--r--src/screen/screen_gameType.h17
-rw-r--r--src/screen/screen_mainMenu.c (renamed from src/screen_mainMenu.c)41
-rw-r--r--src/screen/screen_mainMenu.h15
-rw-r--r--src/screen/screen_setting.c (renamed from src/screen_setting.c)53
-rw-r--r--src/screen/screen_setting.h20
-rw-r--r--src/screen/screen_table.c (renamed from src/screen_table.c)37
-rw-r--r--src/screen/screen_table.h17
-rw-r--r--src/screen/screen_world.c (renamed from src/screen_world.c)85
-rw-r--r--src/screen/screen_world.h31
-rw-r--r--src/server/Makefile15
-rw-r--r--src/server/heightScore.c (renamed from src/heightScore.c)8
-rw-r--r--src/server/heightScore.h13
-rw-r--r--src/server/logFile.c (renamed from src/logFile.c)0
-rw-r--r--src/server/logFile.h18
-rw-r--r--src/server/publicServer.c (renamed from src/publicServer.c)31
-rw-r--r--src/server/publicServer.h18
-rw-r--r--src/server/serverConfigFile.c (renamed from src/serverConfigFile.c)8
-rw-r--r--src/server/serverConfigFile.h11
-rwxr-xr-xsrc/tcp.c235
-rw-r--r--src/tmp10
-rw-r--r--src/widget/Makefile28
-rw-r--r--src/widget/widget_button.c (renamed from src/widget_button.c)10
-rw-r--r--src/widget/widget_button.h27
-rw-r--r--src/widget/widget_buttonimage.c (renamed from src/widget_buttonimage.c)9
-rw-r--r--src/widget/widget_buttonimage.h27
-rw-r--r--src/widget/widget_check.c (renamed from src/widget_check.c)7
-rw-r--r--src/widget/widget_check.h27
-rw-r--r--src/widget/widget_image.c (renamed from src/widget_image.c)8
-rw-r--r--src/widget/widget_image.h21
-rw-r--r--src/widget/widget_label.c (renamed from src/widget_label.c)6
-rw-r--r--src/widget/widget_label.h26
-rw-r--r--src/widget/widget_select.c (renamed from src/widget_select.c)8
-rw-r--r--src/widget/widget_select.h26
-rw-r--r--src/widget/widget_textfield.c (renamed from src/widget_textfield.c)10
-rw-r--r--src/widget/widget_textfield.h33
-rw-r--r--src/zal_pipe.c256
-rw-r--r--src/zal_proto.c692
145 files changed, 4406 insertions, 2958 deletions
diff --git a/src/Makefile b/src/Makefile
index 13f5ba4..a54b508 100755..100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,202 +1,29 @@
-#CC = /usr/local/gcc/bin/gcc
CC = gcc
-
-#CFLAGS = -O2 -DSUPPORT_NET_SDL_UDP -I../include -Wall `sdl-config --cflags`
-CFLAGS = -g -O0 -std=c99 -I../include -Wall `sdl-config --cflags`
-#CFLAGS = -O2 -DDESTDIR=\"$(DESTDIR)\" `sdl-config --cflags` -I../include -Wall
-
-BUILD_DIR = .
-LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_net
-
-FILES = interface.o protect.o space.o idManager.o storage.o font.o list.o modules.o\
- image.o layer.o director.o configFile.o tux.o main.o checkFront.o\
- screen.o screen_world.o shot.o myTimer.o panel.o net_multiplayer.o \
- arena.o arenaFile.o textFile.o audio.o sound.o music.o gun.o \
- item.o widget_label.o screen_mainMenu.o widget_button.o screen_analyze.o widget_textfield.o \
- widget_check.o widget_image.o widget_select.o screen_setting.o screen_gameType.o screen_choiceArena.o \
- widget_buttonimage.o screen_credits.o homeDirector.o screen_table.o \
- sdl_udp.o udp.o proto.o server.o client.o term.o keytable.o language.o game.o
-
-tuxanci-ng: $(FILES)
- $(CC) $(CFLAGS) $(LIBS) -o $(BUILD_DIR)/tuxanci-ng $(BUILD_DIR)/*.o
-
-main.o: main.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/main.o -c main.c
-
-protect.o: protect.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/protect.o -c protect.c
-
-hashTable.o: hashTable.c ../include/hashTable.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/hashTable.o -c hashTable.c
-
-space.o: space.c ../include/space.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/space.o -c space.c
-
-interface.o: interface.c ../include/interface.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/interface.o -c interface.c
-
-storage.o: storage.c ../include/storage.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/storage.o -c storage.c
-
-modules.o: modules.c ../include/modules.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/modules.o -c modules.c
-
-idManager.o: idManager.c ../include/idManager.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/idManager.o -c idManager.c
-
-checkFront.o: checkFront.c ../include/checkFront.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/checkFront.o -c checkFront.c
-
-font.o: font.c ../include/font.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/font.o -c font.c
-
-list.o: list.c ../include/list.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/list.o -c list.c
-
-image.o: image.c ../include/image.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/image.o -c image.c
-
-layer.o: layer.c ../include/layer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/layer.o -c layer.c
-
-director.o: director.c ../include/director.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/director.o -c director.c
-
-configFile.o: configFile.c ../include/configFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/configFile.o -c configFile.c
-
-tux.o: tux.c ../include/tux.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/tux.o -c tux.c
-
-screen.o: screen.c ../include/screen.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen.o -c screen.c
-
-screen_world.o: screen_world.c ../include/screen_world.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_world.o -c screen_world.c
-
-#wall.o: wall.c ../include/wall.h
-# $(CC) $(CFLAGS) -o $(BUILD_DIR)/wall.o -c wall.c
-
-shot.o: shot.c ../include/shot.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/shot.o -c shot.c
-
-myTimer.o: myTimer.c ../include/myTimer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/myTimer.o -c myTimer.c
-
-panel.o: panel.c ../include/panel.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/panel.o -c panel.c
-
-tcp.o: tcp.c ../include/tcp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/tcp.o -c tcp.c
-
-udp.o: udp.c ../include/udp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/udp.o -c udp.c
-
-sdl_udp.o: sdl_udp.c ../include/sdl_udp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/sdl_udp.o -c sdl_udp.c
-
-proto.o: proto.c ../include/proto.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/proto.o -c proto.c
-
-server.o: server.c ../include/server.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/server.o -c server.c
-
-client.o: client.c ../include/client.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/client.o -c client.c
-
-network.o: network.c ../include/network.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/network.o -c network.c
-
-net_multiplayer.o: net_multiplayer.c ../include/net_multiplayer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/net_multiplayer.o -c net_multiplayer.c
-
-arena.o: arena.c ../include/arena.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/arena.o -c arena.c
-
-textFile.o: textFile.c ../include/textFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/textFile.o -c textFile.c
-
-arenaFile.o: arenaFile.c ../include/arenaFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/arenaFile.o -c arenaFile.c
-
-audio.o: audio.c ../include/audio.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/audio.o -c audio.c
-
-sound.o: sound.c ../include/sound.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/sound.o -c sound.c
-
-music.o: music.c ../include/music.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/music.o -c music.c
-
-gun.o: gun.c ../include/gun.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/gun.o -c gun.c
-
-item.o: item.c ../include/item.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/item.o -c item.c
-
-screen_mainMenu.o: screen_mainMenu.c ../include/screen_mainMenu.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_mainMenu.o -c screen_mainMenu.c
-
-screen_analyze.o: screen_analyze.c ../include/screen_analyze.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_analyze.o -c screen_analyze.c
-
-screen_setting.o: screen_setting.c ../include/screen_setting.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_setting.o -c screen_setting.c
-
-screen_gameType.o: screen_gameType.c ../include/screen_gameType.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_gameType.o -c screen_gameType.c
-
-screen_choiceArena.o: screen_choiceArena.c ../include/screen_choiceArena.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_choiceArena.o -c screen_choiceArena.c
-
-screen_credits.o: screen_credits.c ../include/screen_credits.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_credits.o -c screen_credits.c
-
-widget_label.o: widget_label.c ../include/widget_label.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_label.o -c widget_label.c
-
-widget_button.o: widget_button.c ../include/widget_button.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_button.o -c widget_button.c
-
-widget_buttonimage.o: widget_buttonimage.c ../include/widget_buttonimage.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_buttonimage.o -c widget_buttonimage.c
-
-widget_textfield.o: widget_textfield.c ../include/widget_textfield.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_textfield.o -c widget_textfield.c
-
-widget_check.o: widget_check.c ../include/widget_check.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_check.o -c widget_check.c
-
-widget_image.o: widget_image.c ../include/widget_image.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_image.o -c widget_image.c
-
-widget_select.o: widget_select.c ../include/widget_select.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_select.o -c widget_select.c
-
-#teleport.o: teleport.c ../include/teleport.h
-# $(CC) $(CFLAGS) -o $(BUILD_DIR)/teleport.o -c teleport.c
-
-#pipe.o: pipe.c ../include/pipe.h
-# $(CC) $(CFLAGS) -o $(BUILD_DIR)/pipe.o -c pipe.c
-
-homeDirector.o: homeDirector.c ../include/homeDirector.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/homeDirector.o -c homeDirector.c
-
-screen_table.o: screen_table.c ../include/screen_table.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_table.o -c screen_table.c
-
-term.o: term.c ../include/term.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/term.o -c term.c
-
-keytable.o: keytable.c ../include/keytable.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/keytable.o -c keytable.c
-
-language.o: language.c ../include/language.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/language.o -c language.c
-
-game.o: game.c ../include/game.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/game.o -c game.c
+CFLAGS = -g -O0 -std=c99 -I.. -Wall `sdl-config --cflags` -DSUPPORT_NET_UNIX_UDP
+LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer
+
+all:
+ make -C ./audio -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./net_unix -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./client -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./screen -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./widget -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./base -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./modules -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ $(CC) $(CFLAGS) $(LIBS) -o tuxanci-ng base/*.o client/*.o widget/*.o screen/*.o net_unix/*.o audio/*.o
+ cp modules/*.so ../modules/
+ cp tuxanci-ng ../
clean:
- rm -rf *.o *.c~ ../include/*.h~ Makefile~
+ make -C ./base -f Makefile clean
+ make -C ./client -f Makefile clean
+ make -C ./screen -f Makefile clean
+ make -C ./widget -f Makefile clean
+ make -C ./net_unix -f Makefile clean
+ make -C ./net_sdl -f Makefile clean
+ make -C ./audio -f Makefile clean
+ make -C ./modules -f Makefile clean
+ rm -rf ../modules/*.so
+ rm tuxanci-ng
+ rm ../tuxanci-ng
diff --git a/src/Makefile-listserver b/src/Makefile-listserver
deleted file mode 100755
index c2cba31..0000000
--- a/src/Makefile-listserver
+++ /dev/null
@@ -1,27 +0,0 @@
-
-#CC = /usr/local/gcc/bin/gcc
-CC = gcc
-
-#CFLAGS = -O2 -DSUPPORT_NET_SDL_UDP -I../include -Wall `sdl-config --cflags`
-CFLAGS = -g -O0 -std=c99 -D_GNU_SOURCE=1 -I../include -Wall
-#CFLAGS = -O2 -DDESTDIR=\"$(DESTDIR)\" `sdl-config --cflags` -I../include -Wall
-
-BUILD_DIR = .
-LIBS =
-
-FILES = listServer.o udp.o list.o
-
-listServer: $(FILES)
- $(CC) $(CFLAGS) $(LIBS) -o $(BUILD_DIR)/listServer $(BUILD_DIR)/*.o
-
-listServer.o: listServer.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/listServer.o -c listServer.c
-
-list.o: list.c ../include/list.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/list.o -c list.c
-
-udp.o: udp.c ../include/udp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/udp.o -c udp.c
-
-clean:
- rm -rf *.o *.c~ ../include/*.h~ Makefile~
diff --git a/src/Makefile-nosound b/src/Makefile-nosound
index dbe518f..e672fe1 100755..100644
--- a/src/Makefile-nosound
+++ b/src/Makefile-nosound
@@ -1,177 +1,28 @@
-#CC = /usr/local/gcc/bin/gcc
CC = gcc
-
-#CFLAGS = -O2 -DSUPPORT_NET_SDL_UDP -I../include -Wall `sdl-config --cflags`
-CFLAGS = -g -O0 -std=c99 -DNO_SOUND -I../include -Wall `sdl-config --cflags`
-#CFLAGS = -O2 -DDESTDIR=\"$(DESTDIR)\" `sdl-config --cflags` -I../include -Wall
-
-BUILD_DIR = .
-LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_net
-
-FILES = interface.o font.o list.o image.o layer.o director.o configFile.o tux.o main.o \
- screen.o screen_world.o wall.o shot.o myTimer.o panel.o net_multiplayer.o \
- buffer.o dynamicInt.o arena.o arenaFile.o textFile.o fake_audio.o gun.o \
- item.o widget_label.o screen_mainMenu.o widget_button.o screen_analyze.o widget_textfield.o \
- widget_check.o widget_image.o screen_setting.o screen_gameType.o screen_choiceArena.o \
- widget_buttonimage.o screen_credits.o teleport.o pipe.o homeDirector.o screen_table.o \
- sdl_udp.o proto.o server.o client.o term.o keytable.o language.o game.o
-
-tuxanci-ng: $(FILES)
- $(CC) $(CFLAGS) $(LIBS) -o $(BUILD_DIR)/tuxanci-ng $(BUILD_DIR)/*.o
-
-main.o: main.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/main.o -c main.c
-
-interface.o: interface.c ../include/interface.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/interface.o -c interface.c
-
-font.o: font.c ../include/font.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/font.o -c font.c
-
-list.o: list.c ../include/list.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/list.o -c list.c
-
-image.o: image.c ../include/image.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/image.o -c image.c
-
-layer.o: layer.c ../include/layer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/layer.o -c layer.c
-
-director.o: director.c ../include/director.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/director.o -c director.c
-
-configFile.o: configFile.c ../include/configFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/configFile.o -c configFile.c
-
-tux.o: tux.c ../include/tux.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/tux.o -c tux.c
-
-screen.o: screen.c ../include/screen.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen.o -c screen.c
-
-screen_world.o: screen_world.c ../include/screen_world.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_world.o -c screen_world.c
-
-wall.o: wall.c ../include/wall.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/wall.o -c wall.c
-
-shot.o: shot.c ../include/shot.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/shot.o -c shot.c
-
-myTimer.o: myTimer.c ../include/myTimer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/myTimer.o -c myTimer.c
-
-panel.o: panel.c ../include/panel.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/panel.o -c panel.c
-
-buffer.o: buffer.c ../include/buffer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/buffer.o -c buffer.c
-
-tcp.o: tcp.c ../include/tcp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/tcp.o -c tcp.c
-
-udp.o: udp.c ../include/udp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/udp.o -c udp.c
-
-sdl_udp.o: sdl_udp.c ../include/sdl_udp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/sdl_udp.o -c sdl_udp.c
-
-proto.o: proto.c ../include/proto.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/proto.o -c proto.c
-
-server.o: server.c ../include/server.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/server.o -c server.c
-
-client.o: client.c ../include/client.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/client.o -c client.c
-
-network.o: network.c ../include/network.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/network.o -c network.c
-
-net_multiplayer.o: net_multiplayer.c ../include/net_multiplayer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/net_multiplayer.o -c net_multiplayer.c
-
-dynamicInt.o: dynamicInt.c ../include/dynamicInt.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/dynamicInt.o -c dynamicInt.c
-
-arena.o: arena.c ../include/arena.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/arena.o -c arena.c
-
-textFile.o: textFile.c ../include/textFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/textFile.o -c textFile.c
-
-arenaFile.o: arenaFile.c ../include/arenaFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/arenaFile.o -c arenaFile.c
-
-gun.o: gun.c ../include/gun.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/gun.o -c gun.c
-
-item.o: item.c ../include/item.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/item.o -c item.c
-
-screen_mainMenu.o: screen_mainMenu.c ../include/screen_mainMenu.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_mainMenu.o -c screen_mainMenu.c
-
-screen_analyze.o: screen_analyze.c ../include/screen_analyze.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_analyze.o -c screen_analyze.c
-
-screen_setting.o: screen_setting.c ../include/screen_setting.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_setting.o -c screen_setting.c
-
-screen_gameType.o: screen_gameType.c ../include/screen_gameType.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_gameType.o -c screen_gameType.c
-
-screen_choiceArena.o: screen_choiceArena.c ../include/screen_choiceArena.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_choiceArena.o -c screen_choiceArena.c
-
-screen_credits.o: screen_credits.c ../include/screen_credits.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_credits.o -c screen_credits.c
-
-widget_label.o: widget_label.c ../include/widget_label.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_label.o -c widget_label.c
-
-widget_button.o: widget_button.c ../include/widget_button.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_button.o -c widget_button.c
-
-widget_buttonimage.o: widget_buttonimage.c ../include/widget_buttonimage.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_buttonimage.o -c widget_buttonimage.c
-
-widget_textfield.o: widget_textfield.c ../include/widget_textfield.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_textfield.o -c widget_textfield.c
-
-widget_check.o: widget_check.c ../include/widget_check.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_check.o -c widget_check.c
-
-widget_image.o: widget_image.c ../include/widget_image.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_image.o -c widget_image.c
-
-teleport.o: teleport.c ../include/teleport.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/teleport.o -c teleport.c
-
-pipe.o: pipe.c ../include/pipe.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/pipe.o -c pipe.c
-
-homeDirector.o: homeDirector.c ../include/homeDirector.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/homeDirector.o -c homeDirector.c
-
-screen_table.o: screen_table.c ../include/screen_table.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/screen_table.o -c screen_table.c
-
-term.o: term.c ../include/term.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/term.o -c term.c
-
-keytable.o: keytable.c ../include/keytable.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/keytable.o -c keytable.c
-
-language.o: language.c ../include/language.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/language.o -c language.c
-
-game.o: game.c ../include/game.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/game.o -c game.c
-
-fake_audio.o: fake_audio.c ../include/fake_audio.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/fake_audio.o -c fake_audio.c
+CFLAGS = -g -O0 -std=c99 -I.. -Wall `sdl-config --cflags` -DNO_SOUND -DSUPPORT_NET_UNIX_UDP
+LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf
+
+all:
+ make -C ./net_unix -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./client -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./screen -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./widget -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./base -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./modules -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ $(CC) $(CFLAGS) $(LIBS) -o tuxanci-ng base/*.o client/*.o widget/*.o screen/*.o net_unix/*.o
+ cp modules/*.so ../modules/
+ cp tuxanci-ng ../
clean:
- rm -rf *.o *.c~ ../include/*.h~ Makefile~
+ make -C ./base -f Makefile clean
+ make -C ./client -f Makefile clean
+ make -C ./screen -f Makefile clean
+ make -C ./widget -f Makefile clean
+ make -C ./net_unix -f Makefile clean
+ make -C ./net_sdl -f Makefile clean
+ make -C ./audio -f Makefile clean
+ make -C ./modules -f Makefile clean
+ rm -rf ../modules/*.so
+ rm tuxanci-ng
+ rm ../tuxanci-ng
diff --git a/src/Makefile-publicServer b/src/Makefile-publicServer
deleted file mode 100755
index 7f1f30c..0000000
--- a/src/Makefile-publicServer
+++ /dev/null
@@ -1,106 +0,0 @@
-
-#CC = /usr/local/gcc/bin/gcc
-CC = gcc
-
-DESTDIR:=/usr/local
-
-CFLAGS = -g -O0 -I../include -Wall
-#CFLAGS = -O2 -DDESTDIR=\"$(DESTDIR)\" `sdl-config --cflags` -I../include -Wall
-
-BUILD_DIR = ../build-server
-LIBS = -ldl
-
-FILES = list.o space.o protect.o heightScore.o modules.o director.o configFile.o tux.o shot.o myTimer.o \
- arena.o arenaFile.o textFile.o gun.o item.o idManager.o checkFront.o\
- udp.o proto.o server.o publicServer.o net_multiplayer.o serverConfigFile.o main.o
-
-$(BUILD_DIR)/publicserver: mkdir_build $(FILES)
- $(CC) $(CFLAGS) $(LIBS) -o $(BUILD_DIR)/publicserver $(BUILD_DIR)/*.o
-
-mkdir_build:
- mkdir -p $(BUILD_DIR)
-
-protect.o: protect.c ../include/protect.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/protect.o -c protect.c
-
-space.o: space.c ../include/space.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/space.o -c space.c
-
-heightScore.o: heightScore.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/heightScore.o -c heightScore.c
-
-main.o: main.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/main.o -c main.c
-
-idManager.o: idManager.c ../include/idManager.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/idManager.o -c idManager.c
-
-modules.o: modules.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/modules.o -c modules.c
-
-checkFront.o: checkFront.c ../include/checkFront.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/checkFront.o -c checkFront.c
-
-publicServer.o: publicServer.c
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/publicServer.o -c publicServer.c
-
-list.o: list.c ../include/list.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/list.o -c list.c
-
-director.o: director.c ../include/director.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/director.o -c director.c
-
-configFile.o: configFile.c ../include/configFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/configFile.o -c configFile.c
-
-tux.o: tux.c ../include/tux.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/tux.o -c tux.c
-
-shot.o: shot.c ../include/shot.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/shot.o -c shot.c
-
-myTimer.o: myTimer.c ../include/myTimer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/myTimer.o -c myTimer.c
-
-tcp.o: tcp.c ../include/tcp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/tcp.o -c tcp.c
-
-udp.o: udp.c ../include/udp.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/udp.o -c udp.c
-
-proto.o: proto.c ../include/proto.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/proto.o -c proto.c
-
-server.o: server.c ../include/server.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/server.o -c server.c
-
-net_multiplayer.o: net_multiplayer.c ../include/net_multiplayer.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/net_multiplayer.o -c net_multiplayer.c
-
-arena.o: arena.c ../include/arena.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/arena.o -c arena.c
-
-textFile.o: textFile.c ../include/textFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/textFile.o -c textFile.c
-
-arenaFile.o: arenaFile.c ../include/arenaFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/arenaFile.o -c arenaFile.c
-
-gun.o: gun.c ../include/gun.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/gun.o -c gun.c
-
-item.o: item.c ../include/item.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/item.o -c item.c
-
-#teleport.o: teleport.c ../include/teleport.h
-# $(CC) $(CFLAGS) -o $(BUILD_DIR)/teleport.o -c teleport.c
-
-#pipe.o: pipe.c ../include/pipe.h
-# $(CC) $(CFLAGS) -o $(BUILD_DIR)/pipe.o -c pipe.c
-
-serverConfigFile.o: serverConfigFile.c ../include/serverConfigFile.h
- $(CC) $(CFLAGS) -o $(BUILD_DIR)/serverConfigFile.o -c serverConfigFile.c
-
-clean:
- rm -rf $(BUILD_DIR) ../include*.h~ Makefile-publicServer~
-
diff --git a/src/Makefile-sdlnet b/src/Makefile-sdlnet
new file mode 100644
index 0000000..d278d52
--- /dev/null
+++ b/src/Makefile-sdlnet
@@ -0,0 +1,29 @@
+
+CC = gcc
+CFLAGS = -g -O0 -std=c99 -I.. -Wall `sdl-config --cflags` -DSUPPORT_NET_SDL_UDP
+LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_net
+
+all:
+ make -C ./audio -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./net_sdl -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./client -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./screen -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./widget -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./base -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./modules -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ $(CC) $(CFLAGS) $(LIBS) -o tuxanci-ng base/*.o client/*.o widget/*.o screen/*.o net_sdl/*.o audio/*.o
+ cp modules/*.so ../modules/
+ cp tuxanci-ng ../
+
+clean:
+ make -C ./base -f Makefile clean
+ make -C ./client -f Makefile clean
+ make -C ./screen -f Makefile clean
+ make -C ./widget -f Makefile clean
+ make -C ./net_unix -f Makefile clean
+ make -C ./net_sdl -f Makefile clean
+ make -C ./audio -f Makefile clean
+ make -C ./modules -f Makefile clean
+ rm -rf ../modules/*.so
+ rm tuxanci-ng
+ rm ../tuxanci-ng
diff --git a/src/Makefile-server b/src/Makefile-server
new file mode 100644
index 0000000..23ec740
--- /dev/null
+++ b/src/Makefile-server
@@ -0,0 +1,26 @@
+
+CC = gcc
+CFLAGS = -g -O0 -std=c99 -I.. -Wall -D_GNU_SOURCE=1 -DSUPPORT_NET_UNIX_UDP -DPUBLIC_SERVER -DNO_SOUND
+LIBS = -ldl
+
+all:
+ make -C ./base -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./server -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./net_unix -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ make -C ./modules -f Makefile CC="$(CC)" CFLAGS="$(CFLAGS)"
+ $(CC) $(CFLAGS) $(LIBS) -o publicserver base/*.o server/*.o net_unix/*.o
+ cp modules/*.so ../modules/
+ cp publicserver ../
+
+clean:
+ make -C ./base -f Makefile clean
+ make -C ./client -f Makefile clean
+ make -C ./screen -f Makefile clean
+ make -C ./widget -f Makefile clean
+ make -C ./net_unix -f Makefile clean
+ make -C ./net_sdl -f Makefile clean
+ make -C ./audio -f Makefile clean
+ make -C ./modules -f Makefile clean
+ rm -rf ../modules/*.so
+ rm publicserver
+ rm ../publicserver
diff --git a/src/audio/Makefile b/src/audio/Makefile
new file mode 100644
index 0000000..a5dff01
--- /dev/null
+++ b/src/audio/Makefile
@@ -0,0 +1,17 @@
+
+
+all: audio.o music.o sound.o
+
+audio.o: audio.c audio.h
+ $(CC) $(CFLAGS) -o audio.o -c audio.c
+
+music.o: music.c music.h
+ $(CC) $(CFLAGS) -o music.o -c music.c
+
+sound.o: sound.c sound.h
+ $(CC) $(CFLAGS) -o sound.o -c sound.c
+
+
+
+clean:
+ rm -rf *.o
diff --git a/src/audio.c b/src/audio/audio.c
index 8397788..d7f4a9b 100644
--- a/src/audio.c
+++ b/src/audio/audio.c
@@ -3,9 +3,9 @@
#include <assert.h>
#include <SDL_mixer.h>
-#include "main.h"
-#include "audio.h"
-#include "interface.h"
+#include "base/main.h"
+#include "audio/audio.h"
+#include "client/interface.h"
static bool_t isAudioInit = FALSE;
diff --git a/src/audio/audio.h b/src/audio/audio.h
new file mode 100644
index 0000000..04c58e7
--- /dev/null
+++ b/src/audio/audio.h
@@ -0,0 +1,12 @@
+
+#ifndef AUDIO_H
+
+#define AUDIO_H
+
+#include "base/main.h"
+
+extern bool_t isAudioInicialized();
+extern void initAudio();
+extern void quitAudio();
+
+#endif
diff --git a/src/music.c b/src/audio/music.c
index e4fb812..90bc5a0 100644
--- a/src/music.c
+++ b/src/audio/music.c
@@ -3,14 +3,14 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-#include "list.h"
-#include "path.h"
-#include "string_length.h"
-#include "audio.h"
-#include "music.h"
-#include "storage.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/storage.h"
+
+#include "client/interface.h"
+
+#include "audio/audio.h"
+#include "audio/music.h"
static list_t *listStorage;
diff --git a/src/audio/music.h b/src/audio/music.h
new file mode 100644
index 0000000..d87f382
--- /dev/null
+++ b/src/audio/music.h
@@ -0,0 +1,36 @@
+
+#ifndef MUSIC_H
+
+#define MUSIC_H
+
+#ifndef NO_SOUND
+
+#include <SDL_mixer.h>
+#include "base/main.h"
+
+#define MUSIC_GROUP_BASE "base"
+#define MUSIC_GROUP_USER "user"
+
+/*
+typedef struct music_struct
+{
+ char *name;
+ int group;
+ Mix_Music *music;
+} music_t;
+*/
+
+extern bool_t isMusicInicialized();
+extern void initMusic();
+extern void addMusic(char *file, char *name, char *group);
+extern void stopMusic();
+extern void playMusic(char *name, char *group);
+extern void setMusicActive(bool_t n);
+extern bool_t isMusicActive();
+extern char* getCurrentMusic();
+extern void delAllMusicInGroup(char *group);
+extern void quitMusic();
+
+#endif
+
+#endif
diff --git a/src/sound.c b/src/audio/sound.c
index a35d996..37803c4 100644
--- a/src/sound.c
+++ b/src/audio/sound.c
@@ -3,14 +3,14 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-#include "list.h"
-#include "path.h"
-#include "string_length.h"
-#include "audio.h"
-#include "sound.h"
-#include "storage.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/storage.h"
+
+#include "client/interface.h"
+
+#include "audio/audio.h"
+#include "audio/sound.h"
static list_t *listStorage;
diff --git a/src/audio/sound.h b/src/audio/sound.h
new file mode 100644
index 0000000..ec1beb1
--- /dev/null
+++ b/src/audio/sound.h
@@ -0,0 +1,33 @@
+
+#ifndef SOUND_H
+
+#define SOUND_H
+
+#ifndef NO_SOUND
+
+#include <SDL_mixer.h>
+#include "base/main.h"
+
+#define SOUND_GROUP_BASE "base"
+#define SOUND_GROUP_USER "user"
+
+/*
+typedef struct sound_struct
+{
+ char *name;
+ int group;
+ Mix_Chunk *sound;
+} sound_t;
+*/
+
+extern bool_t isSoundInicialized();
+extern void initSound();
+extern void addSound(char *file, char *name, char *group);
+extern void playSound(char *name, char *group);
+extern void setSoundActive(bool_t n);
+extern bool_t isSoundActive();
+extern void quitSound();
+
+#endif
+
+#endif
diff --git a/src/base/Makefile b/src/base/Makefile
new file mode 100644
index 0000000..6de422d
--- /dev/null
+++ b/src/base/Makefile
@@ -0,0 +1,67 @@
+
+all: arena.o arenaFile.o director.o gun.o homeDirector.o checkFront.o idManager.o item.o list.o main.o modules.o myTimer.o net_multiplayer.o protect.o proto.o server.o shot.o space.o storage.o textFile.o tux.o
+
+arena.o: arena.c arena.h
+ $(CC) $(CFLAGS) -o arena.o -c arena.c
+
+arenaFile.o: arenaFile.c arenaFile.h
+ $(CC) $(CFLAGS) -o arenaFile.o -c arenaFile.c
+
+director.o: director.c director.h
+ $(CC) $(CFLAGS) -o director.o -c director.c
+
+gun.o: gun.c gun.h
+ $(CC) $(CFLAGS) -o gun.o -c gun.c
+
+homeDirector.o: homeDirector.c homeDirector.h
+ $(CC) $(CFLAGS) -o homeDirector.o -c homeDirector.c
+
+checkFront.o: checkFront.c checkFront.h
+ $(CC) $(CFLAGS) -o checkFront.o -c checkFront.c
+
+idManager.o: idManager.c idManager.h
+ $(CC) $(CFLAGS) -o idManager.o -c idManager.c
+
+item.o: item.c item.h
+ $(CC) $(CFLAGS) -o item.o -c item.c
+
+list.o: list.c list.h
+ $(CC) $(CFLAGS) -o list.o -c list.c
+
+main.o: main.c main.h
+ $(CC) $(CFLAGS) -o main.o -c main.c
+
+modules.o: modules.c modules.h
+ $(CC) $(CFLAGS) -o modules.o -c modules.c
+
+myTimer.o: myTimer.c myTimer.h
+ $(CC) $(CFLAGS) -o myTimer.o -c myTimer.c
+
+net_multiplayer.o: net_multiplayer.c net_multiplayer.h
+ $(CC) $(CFLAGS) -o net_multiplayer.o -c net_multiplayer.c
+
+protect.o: protect.c protect.h
+ $(CC) $(CFLAGS) -o protect.o -c protect.c
+
+server.o: server.c server.h
+ $(CC) $(CFLAGS) -o server.o -c server.c
+
+shot.o: shot.c shot.h
+ $(CC) $(CFLAGS) -o shot.o -c shot.c
+
+space.o: space.c space.h
+ $(CC) $(CFLAGS) -o space.o -c space.c
+
+storage.o: storage.c storage.h
+ $(CC) $(CFLAGS) -o storage.o -c storage.c
+
+textFile.o: textFile.c textFile.h
+ $(CC) $(CFLAGS) -o textFile.o -c textFile.c
+
+tux.o: tux.c tux.h
+ $(CC) $(CFLAGS) -o tux.o -c tux.c
+
+clean:
+ rm -rf *.o
+
+
diff --git a/src/arena.c b/src/base/arena.c
index d9df24f..448ee5b 100644
--- a/src/arena.c
+++ b/src/base/arena.c
@@ -3,18 +3,18 @@
#include <assert.h>
#include <string.h>
-#include "main.h"
-#include "arena.h"
-#include "list.h"
-#include "tux.h"
-#include "shot.h"
-#include "item.h"
-#include "myTimer.h"
-#include "modules.h"
+#include "base/main.h"
+#include "base/arena.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/item.h"
+#include "base/myTimer.h"
+#include "base/modules.h"
#ifndef PUBLIC_SERVER
-#include "screen_world.h"
-#include "layer.h"
+#include "screen/screen_world.h"
+#include "client/layer.h"
#endif
static arena_t *currentArena;
diff --git a/src/base/arena.h b/src/base/arena.h
new file mode 100644
index 0000000..57792c5
--- /dev/null
+++ b/src/base/arena.h
@@ -0,0 +1,43 @@
+
+#ifndef ARENA_H
+
+#define ARENA_H
+
+#include "base/main.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#endif
+
+#include "base/list.h"
+#include "base/space.h"
+
+typedef struct arena_struct
+{
+#ifndef PUBLIC_SERVER
+ char music[STR_SIZE];
+
+ SDL_Surface *background;
+#endif
+ int w, h;
+ list_t *listTimer;
+ //list_t *listTux;
+ space_t *spaceShot;
+ space_t *spaceTux;
+ space_t *spaceItem;
+} arena_t;
+
+extern void setCurrentArena(arena_t *p);
+extern arena_t* getCurrentArena();
+extern arena_t* newArena(int w, int h);
+extern int conflictSpace(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2);
+extern int isFreeSpace(arena_t *arena, int x, int y, int w, int h);
+extern void findFreeSpace(arena_t *arena, int *x, int *y, int w, int h);
+extern void getCenterScreen(int *screen_x, int *screen_y, int x, int y);
+#ifndef PUBLIC_SERVER
+extern void drawArena(arena_t *arena);
+#endif
+extern void eventArena(arena_t *arena);
+extern void destroyArena(arena_t *p);
+
+#endif
diff --git a/src/arenaFile.c b/src/base/arenaFile.c
index a3383e4..9fe683e 100644
--- a/src/arenaFile.c
+++ b/src/base/arenaFile.c
@@ -4,24 +4,21 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "textFile.h"
-#include "configFile.h"
-#include "arenaFile.h"
-#include "arena.h"
-#include "tux.h"
-#include "shot.h"
-#include "item.h"
-#include "director.h"
-#include "path.h"
-#include "modules.h"
-#include "string_length.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/textFile.h"
+#include "base/arenaFile.h"
+#include "base/arena.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/item.h"
+#include "base/director.h"
+#include "base/modules.h"
#ifndef PUBLIC_SERVER
-#include "image.h"
-#include "music.h"
-#include "fake_audio.h"
+#include "client/configFile.h"
+#include "client/image.h"
+#include "audio/music.h"
#endif
static list_t *listArenaFile;
@@ -33,15 +30,45 @@ bool_t isAreaFileInicialized()
return isArenaFileInit;
}
+int getArenaValue(char *line, char *env, char *val, int len)
+{
+ char *offset_env;
+ char *offset_val_begin;
+ char *offset_val_end;
+ char clone_env[STR_SIZE];
+ int val_len;
+
+ strcpy(clone_env, " ");
+ strcat(clone_env, env);
+
+ offset_env = strstr(line, clone_env);
+ if( offset_env == NULL )return -1;
+
+ offset_val_begin = strchr(offset_env, '"');
+ if( offset_val_begin == NULL )return -1;
+
+ offset_val_end = strchr(offset_val_begin+1, '"');
+ if( offset_val_end == NULL )return -1;
+
+ val_len = (int)(offset_val_end - ( offset_val_begin + 1) );
+ if( val_len > len - 1 ) val_len = len - 1;
+
+ memset(val, 0, len);
+ memcpy(val, offset_val_begin+1, val_len);
+
+ return 0;
+}
+
+
static void cmd_arena(arena_t **arena, char *line)
{
char str_image[STR_SIZE];
char str_w[STR_SIZE];
char str_h[STR_SIZE];
- if( getValue(line, "background", str_image, STR_SIZE) != 0 )return;
- if( getValue(line, "w", str_w, STR_SIZE) != 0 )return;
- if( getValue(line, "h", str_h, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "background", str_image, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "w", str_w, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "h", str_h, STR_SIZE) != 0 )return;
(*arena) = newArena(atoi(str_w), atoi(str_h));
#ifndef PUBLIC_SERVER
@@ -57,7 +84,7 @@ static void cmd_loadModule(char *line)
{
char str_file[STR_SIZE];
- if( getValue(line, "file", str_file, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "file", str_file, STR_SIZE) != 0 )return;
loadModule(str_file);
}
@@ -70,9 +97,9 @@ static void cmd_loadImage(char *line)
char str_name[STR_SIZE];
char str_alpha[STR_SIZE];
- if( getValue(line, "file", str_file, STR_SIZE) != 0 )return;
- if( getValue(line, "name", str_name, STR_SIZE) != 0 )return;
- if( getValue(line, "alpha", str_alpha, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "file", str_file, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "name", str_name, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "alpha", str_alpha, STR_SIZE) != 0 )return;
addImageData(str_file, isYesOrNO(str_alpha), str_name, IMAGE_GROUP_USER);
}
@@ -82,17 +109,19 @@ static void cmd_loadMusic(char *line)
char str_file[STR_SIZE];
char str_name[STR_SIZE];
- if( getValue(line, "file", str_file, STR_SIZE) != 0 )return;
- if( getValue(line, "name", str_name, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "file", str_file, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "name", str_name, STR_SIZE) != 0 )return;
+#ifndef NO_SOUND
addMusic(str_file, str_name, MUSIC_GROUP_USER);
+#endif
}
static void cmd_playMusic(arena_t *arena, char *line)
{
char str_music[STR_SIZE];
- if( getValue(line, "music", str_music, STR_SIZE) != 0 )return;
+ if( getArenaValue(line, "music", str_music, STR_SIZE) != 0 )return;
strcpy(arena->music, str_music);
}
diff --git a/src/base/arenaFile.h b/src/base/arenaFile.h
new file mode 100644
index 0000000..e2e8108
--- /dev/null
+++ b/src/base/arenaFile.h
@@ -0,0 +1,22 @@
+
+#ifndef ARENA_FILE_H
+
+#define ARENA_FILE_H
+
+#include "base/main.h"
+#include "base/arena.h"
+
+#define PUBLIC_SERVER_PATH_ARENA "./arena/"
+
+extern int getArenaValue(char *line, char *env, char *val, int len);
+extern bool_t isArenaFileInicialized();
+extern void initArenaFile();
+extern int getArenaCount();
+extern char *getArenaName(int id);
+extern char *getArenaNetName(int id);
+extern int getArenaIdFormNetName(char *s);
+extern char *getArenaImage(int id);
+extern arena_t* getArena(int id);
+extern void quitArenaFile();
+
+#endif
diff --git a/src/base/bool.h b/src/base/bool.h
new file mode 100644
index 0000000..d122b85
--- /dev/null
+++ b/src/base/bool.h
@@ -0,0 +1,13 @@
+
+#ifndef BOOL_H
+
+#define BOOL_H
+
+#include "main.h"
+
+#define bool_t int
+
+#define TRUE 1
+#define FALSE 0
+
+#endif
diff --git a/src/checkFront.c b/src/base/checkFront.c
index f6164f3..37b0ace 100644
--- a/src/checkFront.c
+++ b/src/base/checkFront.c
@@ -4,12 +4,12 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "myTimer.h"
-#include "checkFront.h"
-#include "idManager.h"
-#include "server.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/myTimer.h"
+#include "base/checkFront.h"
+#include "base/idManager.h"
+#include "base/server.h"
typedef struct struct_checkfront_t
{
diff --git a/src/base/checkFront.h b/src/base/checkFront.h
new file mode 100644
index 0000000..3beb370
--- /dev/null
+++ b/src/base/checkFront.h
@@ -0,0 +1,22 @@
+
+#ifndef CHECK_FRONT_H
+
+#define CHECK_FRONT_H
+
+#include "base/list.h"
+#include "base/server.h"
+
+#define CHECK_FRONT_SEND_TIME_INTERVAL 100
+#define CHECK_FRONT_MAX_COUNT_SEND 30
+
+#define CHECK_FRONT_ID_NONE -1
+#define CHECK_FORNT_TYPE_SIMPLE 1
+#define CHECK_FORNT_TYPE_CHECK 2
+
+extern list_t* newCheckFront();
+extern void addMsgInCheckFront(list_t *list, char *msg, int type, int id);
+extern void eventMsgInCheckFront(client_t *client);
+extern void delMsgInCheckFront(list_t *listCheckFront, int id);
+extern void destroyCheckFront(list_t *p);
+
+#endif
diff --git a/src/director.c b/src/base/director.c
index 6d2fe8c..fede2c3 100755
--- a/src/director.c
+++ b/src/base/director.c
@@ -7,9 +7,8 @@
#include <unistd.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "string_length.h"
+#include "base/main.h"
+#include "base/list.h"
typedef struct director_struct
{
@@ -17,7 +16,6 @@ typedef struct director_struct
list_t *list;
} director_t;
-
director_t* loadDirector(char *s)
{
director_t *new;
diff --git a/src/base/director.h b/src/base/director.h
new file mode 100644
index 0000000..20e577c
--- /dev/null
+++ b/src/base/director.h
@@ -0,0 +1,18 @@
+
+#ifndef DIRECTOR_H
+
+#define DIRECTOR_H
+
+#include "base/main.h"
+#include "base/list.h"
+
+typedef struct director_struct
+{
+ char *path;
+ list_t *list;
+} director_t;
+
+extern director_t* loadDirector(char *s);
+extern void destroyDirector(director_t *p);
+
+#endif
diff --git a/src/fake_audio.c b/src/base/fake_audio.c
index 7bccbde..2149c86 100644
--- a/src/fake_audio.c
+++ b/src/base/fake_audio.c
@@ -1,6 +1,6 @@
-#include "main.h"
-#include "fake_audio.h"
+#include "base/main.h"
+#include "base/fake_audio.h"
bool_t isAudioInicialized()
{
diff --git a/src/gun.c b/src/base/gun.c
index dceec63..3cd6122 100644
--- a/src/gun.c
+++ b/src/base/gun.c
@@ -1,28 +1,29 @@
-//
+
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "arena.h"
-#include "tux.h"
-#include "shot.h"
-#include "myTimer.h"
-#include "item.h"
-#include "gun.h"
-#include "proto.h"
-#include "net_multiplayer.h"
+#include "base/main.h"
+#include "base/arena.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/myTimer.h"
+#include "base/item.h"
+#include "base/gun.h"
+#include "base/proto.h"
+#include "base/net_multiplayer.h"
#ifndef PUBLIC_SERVER
-#include "sound.h"
-#include "fake_audio.h"
-#include "screen_world.h"
-#include "interface.h"
-#include "term.h"
+#include "audio/sound.h"
+
+#include "client/interface.h"
+#include "client/term.h"
+
+#include "screen/screen_world.h"
#endif
#ifdef PUBLIC_SERVER
-#include "publicServer.h"
+#include "server/publicServer.h"
#endif
static void modificiationCopuse(int courser, int right_x, int right_y, int *dest_x, int *dest_y)
@@ -275,7 +276,9 @@ static void putInGunMine(tux_t *tux)
#ifndef PUBLIC_SERVER
char msg[STR_SIZE];
+#ifndef NO_SOUND
playSound("put_mine", SOUND_GROUP_BASE);
+#endif
sprintf(msg, "tux with id %d pu mine\n", tux->id);
appendTextInTerm(msg);
#endif
@@ -311,31 +314,31 @@ void shotInGun(tux_t *tux)
switch( tux->gun )
{
case GUN_SIMPLE :
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("gun_revolver", SOUND_GROUP_BASE);
#endif
shotInGunSimpe(tux);
break;
case GUN_DUAL_SIMPLE :
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("gun_revolver", SOUND_GROUP_BASE);
#endif
shotInGunDualSimpe(tux);
break;
case GUN_SCATTER :
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("gun_scatter", SOUND_GROUP_BASE);
#endif
shotInGunScatter(tux);
break;
case GUN_TOMMY :
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("gun_tommy", SOUND_GROUP_BASE);
#endif
shotInGunTommy(tux);
break;
case GUN_LASSER :
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("gun_lasser", SOUND_GROUP_BASE);
#endif
shotInGunLasser(tux);
diff --git a/src/base/gun.h b/src/base/gun.h
new file mode 100644
index 0000000..4986660
--- /dev/null
+++ b/src/base/gun.h
@@ -0,0 +1,21 @@
+
+#ifndef GUN_H
+
+#define GUN_H
+
+#include "main.h"
+
+#define GUN_SHOT_WIDTH 5
+#define GUN_SHOT_HEIGHT 5
+
+#define GUN_LASSER_HORIZONTAL 50
+#define GUN_SHOT_VERTICAL 5
+
+#define GUN_BOMBBALL_WIDTH 20
+#define GUN_BOMBBALL_HEIGHT 20
+
+#include "tux.h"
+
+extern void shotInGun(tux_t *p);
+
+#endif
diff --git a/src/homeDirector.c b/src/base/homeDirector.c
index e90caae..0533d2e 100755
--- a/src/homeDirector.c
+++ b/src/base/homeDirector.c
@@ -1,13 +1,13 @@
-#include "main.h"
-#include "homeDirector.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <sys/stat.h>
+#include "base/main.h"
+#include "base/homeDirector.h"
+
static char homeDirector[STR_PATH_SIZE];
void createHomeDirector()
diff --git a/src/base/homeDirector.h b/src/base/homeDirector.h
new file mode 100755
index 0000000..a5c5e0c
--- /dev/null
+++ b/src/base/homeDirector.h
@@ -0,0 +1,13 @@
+
+#ifndef HOMEDIRECTOR_H
+
+#define HOMEDIRECTOR_H
+
+#include "base/main.h"
+
+#define HOMEDIRECTOR_NAME ".tuxanci-ng"
+
+extern void createHomeDirector();
+extern char *getHomeDirector();
+
+#endif
diff --git a/src/idManager.c b/src/base/idManager.c
index ea7e679..fb4a928 100644
--- a/src/idManager.c
+++ b/src/base/idManager.c
@@ -3,9 +3,9 @@
#include <stdio.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "idManager.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/idManager.h"
static list_t *listID;
static int lastID;
diff --git a/src/base/idManager.h b/src/base/idManager.h
new file mode 100644
index 0000000..2b33ac5
--- /dev/null
+++ b/src/base/idManager.h
@@ -0,0 +1,19 @@
+
+
+#ifndef ID_MANAGER_H
+
+#define ID_MANAGER_H
+
+#define MAX_ID 1000
+#define ID_UNKNOWN -1
+
+#include "base/list.h"
+
+extern void initListID();
+extern int getNewID();
+extern int isRegisterID(int id);
+extern void delID(int id);
+extern void replaceID(int old_id, int new_id);
+extern void quitListID();
+
+#endif
diff --git a/src/item.c b/src/base/item.c
index 7100e5c..73bfeaa 100644
--- a/src/item.c
+++ b/src/base/item.c
@@ -2,28 +2,33 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "arena.h"
-#include "tux.h"
-#include "item.h"
-#include "shot.h"
-#include "proto.h"
-#include "idManager.h"
-#include "net_multiplayer.h"
+#include "base/main.h"
+#include "base/arena.h"
+#include "base/tux.h"
+#include "base/item.h"
+#include "base/shot.h"
+#include "base/proto.h"
+#include "base/idManager.h"
+#include "base/net_multiplayer.h"
#ifndef PUBLIC_SERVER
-#include "interface.h"
-#include "image.h"
-#include "sound.h"
-#include "fake_audio.h"
-#include "layer.h"
-#include "screen_world.h"
-#include "screen_setting.h"
-#include "term.h"
+
+#include "client/interface.h"
+#include "client/image.h"
+#include "client/layer.h"
+#include "client/term.h"
+
+#include "screen/screen_world.h"
+#include "screen/screen_setting.h"
+
+#ifndef NO_SOUND
+#include "audio/sound.h"
+#endif
+
#endif
#ifdef PUBLIC_SERVER
-#include "publicServer.h"
+#include "server/publicServer.h"
#endif
#ifndef PUBLIC_SERVER
@@ -99,7 +104,7 @@ item_t* newItem(int x, int y, int type, int author_id)
break;
case ITEM_EXPLOSION :
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("explozion", SOUND_GROUP_BASE);
#endif
new->w = ITEM_EXPLOSION_WIDTH;
@@ -107,7 +112,7 @@ item_t* newItem(int x, int y, int type, int author_id)
break;
case ITEM_BIG_EXPLOSION :
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("explozion", SOUND_GROUP_BASE);
#endif
new->w = ITEM_BIG_EXPLOSION_WIDTH;
@@ -470,8 +475,11 @@ static void tuxGiveBonus(tux_t *tux, item_t *item)
{
#ifndef PUBLIC_SERVER
char msg[STR_SIZE];
+#ifndef NO_SOUND
playSound("item_bonus", SOUND_GROUP_BASE);
#endif
+
+#endif
tux->bonus = item->type;
tux->bonus_time = TUX_MAX_BONUS;
@@ -490,8 +498,10 @@ static void tuxGiveGun(tux_t *tux, item_t *item)
{
#ifndef PUBLIC_SERVER
char msg[STR_SIZE];
+#ifndef NO_SOUND
playSound("item_gun", SOUND_GROUP_BASE);
#endif
+#endif
tux->pickup_time = 0;
tux->shot[ item->type ] += GUN_MAX_SHOT;
diff --git a/src/base/item.h b/src/base/item.h
new file mode 100644
index 0000000..ec11654
--- /dev/null
+++ b/src/base/item.h
@@ -0,0 +1,79 @@
+
+#ifndef ITEM_H
+
+#define ITEM_H
+
+#include "base/main.h"
+
+#define ITEM_SYNC_TIMEOUT 5000
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#endif
+
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/myTimer.h"
+
+typedef struct item_struct
+{
+ int id;
+ int type; // typ veci
+
+ int x; // poloha veci
+ int y;
+
+ int w; // rozmery veci
+ int h;
+
+ int frame; //poradove cislo animacie
+ int count;
+
+ int author_id;
+#ifndef PUBLIC_SERVER
+ SDL_Surface *img; //obrazok
+#endif
+} item_t;
+
+#define ITEM_MAX_COUNT 1
+
+#define ITEM_GUN_MAX_FRAME 8
+#define ITEM_MINE_MAX_FRAME 1
+#define ITEM_EXPLOSION_MAX_FRAME 10
+#define ITEM_BONUS_MAX_FRAME 8
+
+#define ITEM_GUN_WIDTH 50
+#define ITEM_GUN_HEIGHT 20
+
+#define ITEM_MINE_WIDTH 15
+#define ITEM_MINE_HEIGHT 11
+
+#define ITEM_EXPLOSION_WIDTH 40
+#define ITEM_EXPLOSION_HEIGHT 40
+
+#define ITEM_BIG_EXPLOSION_WIDTH 100
+#define ITEM_BIG_EXPLOSION_HEIGHT 100
+
+#define ITEM_BONUS_WIDTH 20
+#define ITEM_BONUS_HEIGHT 20
+
+extern bool_t isItemInicialized();
+extern void initItem();
+extern item_t* newItem(int x, int y, int type, int author_id);
+extern void getStatusItem(void *p, int *id, int *x, int *y ,int *w, int *h);
+extern void setStatusItem(void *p, int x, int y, int w, int h);
+extern void replaceItemID(item_t *item, int id);
+extern void addNewItem(space_t *spaceItem, int author_id);
+#ifndef PUBLIC_SERVER
+extern void drawListItem(list_t *listItem);
+#endif
+extern void eventListItem(space_t *listSpace);
+extern void mineExplosion(space_t *spaceItem, item_t *item);
+extern void eventConflictShotWithItem(arena_t *arena);
+extern void eventGiveTuxItem(tux_t *tux, item_t *item, space_t *spaceItem);
+extern void eventGiveTuxListItem(tux_t *tux, space_t *spaceItem);
+extern void destroyItem(item_t *p);
+extern void quitItem();
+
+#endif
+
diff --git a/src/list.c b/src/base/list.c
index 27b0ed8..d182210 100755
--- a/src/list.c
+++ b/src/base/list.c
@@ -1,6 +1,6 @@
-#include "main.h"
-#include "list.h"
+#include "base/main.h"
+#include "base/list.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/base/list.h b/src/base/list.h
new file mode 100755
index 0000000..17a8e2d
--- /dev/null
+++ b/src/base/list.h
@@ -0,0 +1,33 @@
+
+#ifndef LIST_H
+
+#define LIST_H
+
+#include "base/main.h"
+
+#define LIST_ALLOC_LIMIT 16
+
+typedef struct list_str
+{
+ void **list;
+ int count;
+ int alloc;
+} list_t;
+
+extern list_t* newList();
+extern list_t* cloneList(list_t *p);
+extern list_t* cloneListItem(list_t *p, void *f);
+
+extern void addList(list_t *p, void *item);
+extern void insList(list_t *p, int n, void *item);
+extern void *getList(list_t *p,int n);
+extern int searchListItem(list_t *p, void *n);
+
+extern void delList(list_t *p,int n);
+extern void delListItem(list_t *p,int n,void *f);
+extern void listDoEmpty(list_t *p);
+
+extern void destroyList(list_t *p);
+extern void destroyListItem(list_t *p,void *f);
+
+#endif
diff --git a/src/main.c b/src/base/main.c
index f2482f3..ffebbe0 100644
--- a/src/main.c
+++ b/src/base/main.c
@@ -8,14 +8,15 @@
#include <assert.h>
#include <sys/stat.h>
-#include "main.h"
-#include "tux.h"
-#include "game.h"
+#include "base/main.h"
+#include "base/tux.h"
-#ifdef PUBLIC_SERVER
-
-#include "publicServer.h"
+#ifndef PUBLIC_SERVER
+#include "client/game.h"
+#endif
+#ifdef PUBLIC_SERVER
+#include "server/publicServer.h"
#endif
static int my_argc;
diff --git a/src/base/main.h b/src/base/main.h
new file mode 100644
index 0000000..b38a1d7
--- /dev/null
+++ b/src/base/main.h
@@ -0,0 +1,33 @@
+
+#ifndef MAIN_H
+
+#define MAIN_H
+
+#include "../../config.h"
+
+#if defined PUBLIC_SERVER
+
+#undef DESTDIR
+
+#endif
+
+#include "base/bool.h"
+#include "base/string_length.h"
+#include "base/path.h"
+
+//rozlisenie obrazovky
+#define WINDOW_SIZE_X 800
+#define WINDOW_SIZE_Y 600
+
+#include "base/list.h"
+
+extern list_t *listHelp;
+
+extern char* getParam(char *s);
+extern char* getParamElse(char *s1, char *s2);
+extern bool_t isParamFlag(char *s);
+extern char *getString(int n);
+extern int* newInt(int x);
+extern void accessExistFile(const char *s);
+
+#endif
diff --git a/src/modules.c b/src/base/modules.c
index 34224a4..aa881d5 100755
--- a/src/modules.c
+++ b/src/base/modules.c
@@ -5,21 +5,20 @@
#include <dlfcn.h>
#include <assert.h>
-#include "main.h"
-#include "configFile.h"
-#include "list.h"
-#include "path.h"
-#include "tux.h"
-#include "shot.h"
-#include "modules.h"
-#include "tux.h"
-#include "arena.h"
-#include "proto.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/modules.h"
+#include "base/arena.h"
+#include "base/arenaFile.h"
+#include "base/proto.h"
#ifndef PUBLIC_SERVER
-#include "interface.h"
-#include "image.h"
-#include "layer.h"
+#include "client/interface.h"
+#include "client/image.h"
+#include "client/layer.h"
+#include "client/configFile.h"
#endif
int pokus(char *s)
@@ -34,7 +33,7 @@ static export_fce_t export_fce =
.fce_addLayer = addLayer,
.fce_getImage = getImage,
#endif
- .fce_getValue = getValue,
+ .fce_getValue = getArenaValue,
.fce_getNetTypeGame = getNetTypeGame,
.fce_getTuxProportion = getTuxProportion,
.fce_setTuxProportion = setTuxProportion,
diff --git a/src/base/modules.h b/src/base/modules.h
new file mode 100644
index 0000000..3b50ade
--- /dev/null
+++ b/src/base/modules.h
@@ -0,0 +1,78 @@
+
+#ifndef MODULE_H
+
+#define MODULE_H
+
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/arena.h"
+#include "base/proto.h"
+#include "base/myTimer.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/image.h"
+#endif
+
+typedef struct export_fce_s
+{
+ int (*fce_getValue)(char *line, char *env, char *val, int len);
+
+#ifndef PUBLIC_SERVER
+ SDL_Surface* (*fce_getImage)(char *group, char *name);
+
+ void (*fce_addLayer)(SDL_Surface *img,
+ int x,int y, int px,int py,
+ int w,int h, int player);
+#endif
+
+ int (*fce_getNetTypeGame)();
+
+ void (*fce_getTuxProportion)(tux_t *tux, int *x,int *y, int *w, int *h);
+ void (*fce_setTuxProportion)(tux_t *tux, int x, int y);
+ tux_t* (*fce_getTuxID)(list_t *listTux, int id);
+ void (*fce_actionTux)(tux_t *tux, int action);
+
+ arena_t* (*fce_getCurrentArena)();
+ int (*fce_conflictSpace)(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2);
+ int (*fce_isFreeSpace)(arena_t *arena, int x, int y, int w, int h);
+ void (*fce_findFreeSpace)(arena_t *arena, int *x, int *y, int w, int h);
+ void (*fce_proto_send_newtux_server)(int type, client_t *client, tux_t *tux);
+ void (*fce_proto_send_shot_server)(int type, client_t *client, shot_t *p);
+
+ my_time_t (*fce_getMyTime)();
+
+ void (*fce_destroyShot)(shot_t *p);
+ void (*fce_boundBombBall)(shot_t *shot);
+ void (*fce_transformOnlyLasser)(shot_t *shot);
+
+ int (*fce_pokus)(char *s);
+
+} export_fce_t;
+
+typedef struct module_s
+{
+ char *file;
+ void *image;
+
+ int (*fce_init)(export_fce_t *p);
+#ifndef PUBLIC_SERVER
+ int (*fce_draw)(int x, int y,int w, int h);
+#endif
+ int (*fce_event)();
+ int (*fce_isConflict)(int x, int y, int w, int h);
+ void (*fce_cmd)(char *line);
+ int (*fce_destroy)();
+
+} module_t;
+
+extern void initModule();
+extern int loadModule(char *name);
+#ifndef PUBLIC_SERVER
+extern void drawModule(int x, int y, int w, int h);
+#endif
+extern void eventModule();
+extern void cmdModule(char *s);
+extern int isConflictModule(int x, int y, int w, int h);
+extern void quitModule();
+
+#endif
diff --git a/src/myTimer.c b/src/base/myTimer.c
index 89696e6..7913f8b 100644
--- a/src/myTimer.c
+++ b/src/base/myTimer.c
@@ -6,15 +6,14 @@
#include <sys/time.h>
#include <signal.h>
-#include "main.h"
-#include "list.h"
-#include "myTimer.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/myTimer.h"
#ifndef PUBLIC_SERVER
-#include "interface.h"
+#include "client/interface.h"
#endif
-
static struct timeval start = { .tv_sec = 0, .tv_usec = 0 };
list_t* newTimer()
diff --git a/src/base/myTimer.h b/src/base/myTimer.h
new file mode 100644
index 0000000..2f038da
--- /dev/null
+++ b/src/base/myTimer.h
@@ -0,0 +1,32 @@
+
+#ifndef MY_TIME_H
+
+#define MY_TIME_H
+
+#include "base/main.h"
+#include "base/list.h"
+
+#define my_time_t unsigned int
+
+#define TIMER_ONE 0
+#define TIMER_PERIODIC 1
+
+typedef struct my_timer_struct
+{
+ unsigned int id;
+ void (*fce)(void *p);
+ void *arg;
+ int type;
+ my_time_t createTime;
+ my_time_t time;
+} my_timer_t;
+
+extern list_t* newTimer();
+extern void restartTimer();
+extern my_time_t getMyTime();
+extern int addTaskToTimer(list_t *listTimer, int type, void (*fce)(void *p), void *arg, my_time_t my_time);
+extern void eventTimer(list_t *listTimer);
+extern void delTimer(list_t *listTimer, int id);
+extern void destroyTimer(list_t *listTimer);
+
+#endif
diff --git a/src/net_multiplayer.c b/src/base/net_multiplayer.c
index a9132e3..bc8ecab 100644
--- a/src/net_multiplayer.c
+++ b/src/base/net_multiplayer.c
@@ -4,24 +4,28 @@
#include <assert.h>
#include <unistd.h>
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "item.h"
-#include "buffer.h"
-#include "string_length.h"
-#include "arenaFile.h"
-#include "net_multiplayer.h"
-#include "server.h"
-#include "udp.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/item.h"
+#include "base/arenaFile.h"
+#include "base/net_multiplayer.h"
+#include "base/server.h"
+
+#ifdef SUPPORT_NET_UNIX_UDP
+#include "net_unix/udp.h"
+#endif
+
+#ifdef SUPPORT_NET_SDL_UDP
+#include "net_sdl/sdl_udp.h"
+#endif
#ifndef PUBLIC_SERVER
-#include "sdl_udp.h"
-#include "tcp.h"
-#include "screen.h"
-#include "screen_setting.h"
-#include "screen_choiceArena.h"
-#include "client.h"
+#include "screen/screen_setting.h"
+#include "screen/screen_choiceArena.h"
+
+#include "client/screen.h"
+#include "client/client.h"
#endif
static int netGameType;
diff --git a/src/base/net_multiplayer.h b/src/base/net_multiplayer.h
new file mode 100644
index 0000000..ad5eb41
--- /dev/null
+++ b/src/base/net_multiplayer.h
@@ -0,0 +1,35 @@
+
+#ifndef NET_MULTIPLAYER_H
+
+#define NET_MULTIPLAYER_H
+
+#include "base/main.h"
+#include "base/tux.h"
+#include "base/item.h"
+#include "base/arena.h"
+
+#define PROTO_UDPv4 0
+#define PROTO_UDPv6 1
+
+#define NET_GAME_TYPE_NONE 0
+#define NET_GAME_TYPE_SERVER 1
+#define NET_GAME_TYPE_CLIENT 2
+
+#define NET_STATUS_OK 0
+#define NET_STATUS_ZOMBIE 1
+
+#define NET_PROTOCOL_TYPE_TCP 0
+#define NET_PROTOCOL_TYPE_UDP 1
+
+#define LIMIT_BUFFER 10240
+
+#ifdef PUBLIC_SERVER
+extern int initNetMulitplayerPublicServer(char *ip4, int port4, char *ip6, int port6);
+#endif
+
+extern int initNetMuliplayer(int type, char *ip, int port, int proto);
+extern int getNetTypeGame();
+extern void eventNetMultiplayer();
+extern void quitNetMultiplayer();
+
+#endif
diff --git a/src/base/path.h b/src/base/path.h
new file mode 100644
index 0000000..9c26ea4
--- /dev/null
+++ b/src/base/path.h
@@ -0,0 +1,33 @@
+
+#ifndef PATH_H
+
+#define PATH_H
+
+#include "base/main.h"
+
+#ifdef DESTDIR
+
+#define PATH_DIR "share/tuxanci-ng/"
+
+#endif
+
+#ifndef DESTDIR
+
+#define PATH_DIR "./"
+
+#undef DESTDIR
+#define DESTDIR ""
+
+#endif
+
+#define PATH_IMAGE DESTDIR PATH_DIR "image/"
+#define PATH_FONT DESTDIR PATH_DIR "font/"
+#define PATH_ARENA DESTDIR PATH_DIR "arena/"
+#define PATH_SOUND DESTDIR PATH_DIR "sound/"
+#define PATH_MUSIC DESTDIR PATH_DIR "music/"
+#define PATH_CONFIG DESTDIR PATH_DIR "conf/"
+#define PATH_LANG DESTDIR PATH_DIR "lang/"
+#define PATH_DATA DESTDIR PATH_DIR "data/"
+#define PATH_MODULES DESTDIR PATH_DIR "modules/"
+
+#endif
diff --git a/src/protect.c b/src/base/protect.c
index fe9d29d..074873a 100644
--- a/src/protect.c
+++ b/src/base/protect.c
@@ -4,9 +4,9 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "myTimer.h"
-#include "protect.h"
+#include "base/main.h"
+#include "base/myTimer.h"
+#include "base/protect.h"
protect_t* newProtect()
{
diff --git a/src/base/protect.h b/src/base/protect.h
new file mode 100644
index 0000000..b0db5a9
--- /dev/null
+++ b/src/base/protect.h
@@ -0,0 +1,30 @@
+
+#ifndef PROTECT_H
+
+#define PROTECT_H
+
+#include "base/main.h"
+#include "base/myTimer.h"
+
+#define PROTECT_PING_INTERVAL_TIMEOUT 5000
+#define PROTECT_SPEED_INTERVAL_TIMEOUT 40
+#define PROTECT_SPEED_AVARAGE 10
+
+typedef struct protect_struct
+{
+ my_time_t lastPing;
+
+ my_time_t lastMove;
+ my_time_t avarage;
+ int count;
+
+ bool_t isDown;
+} protect_t;
+
+extern protect_t* newProtect();
+extern void refreshLastMove(protect_t *p);
+extern void rereshLastPing(protect_t *p);
+extern bool_t isDown(protect_t *p);
+extern void destroyProtect(protect_t *p);
+
+#endif
diff --git a/src/proto.c b/src/base/proto.c
index 4f71531..52c9dd6 100644
--- a/src/proto.c
+++ b/src/base/proto.c
@@ -4,34 +4,33 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "item.h"
-#include "shot.h"
-#include "arenaFile.h"
-#include "myTimer.h"
-#include "server.h"
-#include "proto.h"
-#include "net_multiplayer.h"
-#include "checkFront.h"
-#include "idManager.h"
-#include "protect.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/item.h"
+#include "base/shot.h"
+#include "base/arenaFile.h"
+#include "base/myTimer.h"
+#include "base/server.h"
+#include "base/proto.h"
+#include "base/net_multiplayer.h"
+#include "base/checkFront.h"
+#include "base/idManager.h"
+#include "base/protect.h"
#ifndef PUBLIC_SERVER
-#include "language.h"
-#include "network.h"
-#include "screen_world.h"
-#include "screen_setting.h"
-#include "screen_choiceArena.h"
-#include "screen_analyze.h"
-#include "client.h"
-#include "term.h"
+#include "client/language.h"
+#include "screen/screen_world.h"
+#include "screen/screen_setting.h"
+#include "screen/screen_choiceArena.h"
+#include "screen/screen_analyze.h"
+#include "client/client.h"
+#include "client/term.h"
#endif
#ifdef PUBLIC_SERVER
-#include "heightScore.h"
-#include "publicServer.h"
+#include "server/heightScore.h"
+#include "server/publicServer.h"
#endif
void proto_send_error_server(int type, client_t *client, int errorcode)
diff --git a/src/base/proto.h b/src/base/proto.h
new file mode 100644
index 0000000..9fe9303
--- /dev/null
+++ b/src/base/proto.h
@@ -0,0 +1,81 @@
+
+#ifndef MY_PROTO
+
+#define MY_PROTO
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/item.h"
+#include "base/shot.h"
+#include "base/arenaFile.h"
+#include "base/myTimer.h"
+#include "base/server.h"
+#include "base/proto.h"
+#include "base/net_multiplayer.h"
+
+#ifndef PUBLIC_SERVER
+#include "screen/screen_world.h"
+#include "screen/screen_setting.h"
+#include "screen/screen_choiceArena.h"
+#include "client/client.h"
+#endif
+
+#ifdef PUBLIC_SERVER
+#include "server/publicServer.h"
+#endif
+
+#define PROTO_SEND_ONE 0
+#define PROTO_SEND_ALL 1
+#define PROTO_SEND_BUT 3
+#define PROTO_SEND_ALL_SEES_TUX 4
+
+#define PROTO_ERROR_CODE_UNKNOWN 0
+#define PROTO_ERROR_CODE_BAD_VERSION 1
+#define PROTO_ERROR_CODE_BAD_NAME 2
+#define PROTO_ERROR_CODE_BAD_COMMAND 3
+#define PROTO_ERROR_CODE_TIMEOUT 4
+
+extern void proto_send_error_server(int type, client_t *client, int errorcode);
+extern void proto_recv_error_client(char *msg);
+extern void proto_send_hello_client(char *name);
+extern void proto_recv_hello_server(client_t *client, char *msg);
+extern void proto_send_status_server(int type, client_t *client);
+extern void proto_recv_status_server(client_t *client, char *msg);
+extern void proto_send_listscore_server(int type, client_t *client, int max);
+extern void proto_recv_listscore_server(client_t *client, char *msg);
+extern void proto_send_check_client(int id);
+extern void proto_recv_check_server(client_t *client, char *msg);
+extern void proto_send_init_server(int type, client_t *client, client_t *client2);
+extern void proto_recv_init_client(char *msg);
+extern void proto_send_event_server(int type, client_t *client, tux_t *tux, int action);
+extern void proto_recv_event_client(char *msg);
+extern void proto_send_event_client(int action);
+extern void proto_recv_event_server(client_t *client, char *msg);
+extern void proto_send_newtux_server(int type, client_t *client, tux_t *tux);
+extern void proto_recv_newtux_client(char *msg);
+extern void proto_send_kill_server(int type, client_t *client, tux_t *tux);
+extern void proto_recv_kill_client(char *msg);
+extern void proto_send_score_server(int type, client_t *client, tux_t *tux);
+extern void proto_recv_score_client(char *msg);
+extern void proto_send_del_server(int type, client_t *client, int id);
+extern void proto_recv_del_client(char *msg);
+extern void proto_send_additem_server(int type, client_t *client, item_t *p);
+extern void proto_recv_additem_client(char *msg);
+extern void proto_send_shot_server(int type, client_t *client, shot_t *p);
+extern void proto_recv_shot_client(char *msg);
+extern void proto_send_ping_client();
+extern void proto_recv_ping_server(client_t *client, char *msg);
+extern void proto_send_ping_server(int type, client_t *client);
+extern void proto_recv_ping_client(char *msg);
+extern void proto_send_end_server(int type, client_t *client);
+extern void proto_recv_end_client(char *msg);
+extern void proto_send_end_client();
+extern void proto_recv_end_server(client_t *client, char *msg);
+
+#endif
+
diff --git a/src/server.c b/src/base/server.c
index 7d5c198..ae9f170 100644
--- a/src/server.c
+++ b/src/base/server.c
@@ -12,36 +12,34 @@
#include <sys/ioctl.h>
#include <sys/time.h>
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "network.h"
-#include "proto.h"
-#include "server.h"
-#include "assert.h"
-#include "myTimer.h"
-#include "arena.h"
-#include "net_multiplayer.h"
-#include "checkFront.h"
-#include "protect.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/proto.h"
+#include "base/server.h"
+#include "base/myTimer.h"
+#include "base/arena.h"
+#include "base/net_multiplayer.h"
+#include "base/checkFront.h"
+#include "base/protect.h"
#ifndef PUBLIC_SERVER
-#include "screen_world.h"
+#include "screen/screen_world.h"
#endif
#ifdef PUBLIC_SERVER
-#include "publicServer.h"
-#include "heightScore.h"
+#include "server/publicServer.h"
+#include "server/heightScore.h"
#endif
#ifdef SUPPORT_NET_UNIX_UDP
-#include "udp.h"
+#include "net_unix/udp.h"
static sock_udp_t *sock_server_udp;
static sock_udp_t *sock_server_udp_second;
#endif
#ifdef SUPPORT_NET_SDL_UDP
-#include "sdl_udp.h"
+#include "net_sdl/sdl_udp.h"
static sock_sdl_udp_t *sock_server_sdl_udp;
#endif
diff --git a/src/base/server.h b/src/base/server.h
new file mode 100644
index 0000000..4a946ea
--- /dev/null
+++ b/src/base/server.h
@@ -0,0 +1,93 @@
+
+#ifndef MY_SERVER
+
+#define MY_SERVER
+
+#include <time.h>
+
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/myTimer.h"
+#include "base/protect.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#endif
+
+
+#ifdef SUPPORT_NET_SDL_UDP
+
+#include "net_sdl/sdl_udp.h"
+
+#endif
+
+#ifdef SUPPORT_NET_UNIX_UDP
+
+#include "net_unix/udp.h"
+
+#endif
+
+#define SERVER_TIMEOUT 1000
+#define SERVER_TIME_SYNC 1000
+#define SERVER_TIME_PING 1000
+#define SERVER_MAX_CLIENTS 100
+
+
+#define SERVER_INDEX_ROOT_TUX 0
+
+typedef struct client_struct
+{
+#ifdef SUPPORT_NET_UNIX_UDP
+ sock_udp_t *socket_udp;
+#endif
+
+#ifdef SUPPORT_NET_SDL_UDP
+ sock_sdl_udp_t *socket_sdl_udp;
+#endif
+ int status;
+
+ tux_t *tux;
+
+ protect_t *protect;
+
+ list_t *listSendMsg;
+ list_t *listRecvMsg;
+} client_t;
+
+#ifdef PUBLIC_SERVER
+extern int initUdpPublicServer(char *ip4, int port4, char *ip6, int port6);
+#endif
+
+#ifdef SUPPORT_NET_UNIX_UDP
+extern int initUdpServer(char *ip, int port, int proto);
+extern int initUdpServerMultiProto(char *ip4, char *ip6, int port4, int port6);
+extern client_t* newUdpClient(sock_udp_t *sock_udp);
+extern int selectServerUdpSocket();
+extern void quitUdpServer();
+#endif
+
+#ifdef SUPPORT_NET_SDL_UDP
+extern int initSdlUdpServer(int port);
+extern client_t* newSdlUdpClient(sock_sdl_udp_t *sock_udp);
+extern void selectServerSdlUdpSocket();
+extern void quitSdlUdpServer();
+#endif
+
+extern void destroyClient(client_t *p);
+
+extern time_t getUpdateServer();
+extern list_t* getListServerClient();
+extern int getServerMaxClients();
+extern void setServerMaxClients(int n);
+
+extern void sendClient(client_t *p, char *msg);
+extern void protoSendClient(int type, client_t *client, char *msg, int type2, int id);
+
+extern tux_t *getServerTux();
+extern client_t *getClientFromTux(tux_t *tux);
+extern void eventClientListBuffer();
+extern void sendInfoCreateClient(client_t *client);
+extern void eventServer();
+
+#endif
+
diff --git a/src/shot.c b/src/base/shot.c
index 50e6e9a..e8cdff9 100644
--- a/src/shot.c
+++ b/src/base/shot.c
@@ -3,21 +3,21 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "shot.h"
-#include "gun.h"
-#include "net_multiplayer.h"
-#include "proto.h"
-#include "idManager.h"
+#include "base/main.h"
+#include "base/shot.h"
+#include "base/gun.h"
+#include "base/net_multiplayer.h"
+#include "base/proto.h"
+#include "base/idManager.h"
#ifndef PUBLIC_SERVER
-#include "image.h"
-#include "screen_world.h"
-#include "layer.h"
+#include "client/image.h"
+#include "client/layer.h"
+#include "screen/screen_world.h"
#endif
#ifdef PUBLIC_SERVER
-#include "publicServer.h"
+#include "server/publicServer.h"
#endif
#ifndef PUBLIC_SERVER
diff --git a/src/base/shot.h b/src/base/shot.h
new file mode 100644
index 0000000..db157cb
--- /dev/null
+++ b/src/base/shot.h
@@ -0,0 +1,61 @@
+
+#ifndef SHOT_H
+
+#define SHOT_H
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/arena.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#endif
+
+typedef struct shot_struct
+{
+ int id;
+
+ int x;
+ int y;
+
+ int w;
+ int h;
+
+ int px;
+ int py;
+
+ int position;
+ int gun;
+
+ int author_id;
+ bool_t isCanKillAuthor;
+
+#ifndef PUBLIC_SERVER
+ SDL_Surface *img;
+#endif
+} shot_t;
+
+extern bool_t isShotInicialized();
+extern void initShot();
+extern shot_t* newShot(int x,int y, int px, int py, int gun, int author_id);
+extern shot_t* getShotID(list_t *listShot, int id);
+extern void replaceShotID(shot_t *shot, int id);
+extern void getStatusShot(void *p, int *id, int *x,int *y, int *w, int *h);
+extern void setStatusShot(void *p, int x, int y, int w, int h);
+#ifndef PUBLIC_SERVER
+extern void drawShot(shot_t *p);
+extern void drawListShot(list_t *listShot);
+#endif
+extern int isConflictWithListShot(list_t *listShot, int x, int y, int w, int h);
+extern void eventMoveListShot(arena_t *arena);
+extern void checkShotIsInTuxScreen(arena_t *arena);
+
+extern void boundBombBall(shot_t *shot);
+extern void transformOnlyLasser(shot_t *shot);
+
+extern void destroyShot(shot_t *p);
+extern void quitShot();
+
+#endif
+
diff --git a/src/space.c b/src/base/space.c
index 0d3060a..0d3060a 100644
--- a/src/space.c
+++ b/src/base/space.c
diff --git a/src/base/space.h b/src/base/space.h
new file mode 100644
index 0000000..de31768
--- /dev/null
+++ b/src/base/space.h
@@ -0,0 +1,38 @@
+
+#ifndef SPACE_H
+
+#define SPACE_H
+
+#include "main.h"
+#include "list.h"
+
+typedef struct space_struct
+{
+ int w;
+ int h;
+ int segW;
+ int segH;
+ list_t ***area;
+ list_t *list;
+ void (*getStatus)(void *p, int *id, int *x, int *y, int *w, int *h);
+ void (*setStatus)(void *p, int x, int y, int w, int h);
+} space_t;
+
+extern space_t *newSpace(int w, int h, int segW, int segH,
+ void (*getStatus)(void *p, int *id, int *x, int *y, int *w, int *h),
+ void (*setStatus)(void *p, int x, int y, int w, int h));
+
+extern void addObjectToSpace(space_t *p, void *item);
+extern void getObjectFromSpace(space_t *p, int x, int y, int w, int h, list_t *list);
+extern void* getObjectFromSpaceWithID(space_t *p, int id);
+extern int isConflictWithObjectFromSpace(space_t *p, int x, int y, int w, int h);
+extern int isConflictWithObjectFromSpaceBut(space_t *p, int x, int y, int w, int h, void *but);
+extern void delObjectFromSpace(space_t *p, void *item);
+extern void delObjectFromSpaceWithObject(space_t *p, void *item, void *f);
+extern void moveObjectInSpace(space_t *p, void *item, int move_x, int move_y);
+extern void printSpace(space_t *p);
+extern void destroySpace(space_t *p);
+extern void destroySpaceWithObject(space_t *p, void *f);
+
+#endif
+
diff --git a/src/storage.c b/src/base/storage.c
index e7afa45..e7afa45 100644
--- a/src/storage.c
+++ b/src/base/storage.c
diff --git a/src/base/storage.h b/src/base/storage.h
new file mode 100644
index 0000000..af72ba2
--- /dev/null
+++ b/src/base/storage.h
@@ -0,0 +1,16 @@
+
+#ifndef STORAGE_H
+
+#define STORAGE_H
+
+#include "base/main.h"
+#include "base/list.h"
+
+extern list_t* newStorage();
+extern void addItemToStorage(list_t *list, char *group, char *name, void *data);
+extern void* getItemFromStorage(list_t *list, char *group, char *name);
+extern void delItemFromStorage(list_t *list, char *group, char *name, void *f);
+extern void delAllItemFromStorage(list_t *list, char *group, void *f);
+extern void destroyStorage(list_t *p, void *f);
+
+#endif
diff --git a/src/base/string_length.h b/src/base/string_length.h
new file mode 100644
index 0000000..c453e60
--- /dev/null
+++ b/src/base/string_length.h
@@ -0,0 +1,16 @@
+
+#ifndef STR_LENGTH_H
+
+#define STR_LENGTH_H
+
+#include "base/main.h"
+
+#define STR_SIZE 128
+#define STR_PROTO_SIZE 128
+#define STR_NUM_SIZE 8
+#define STR_NAME_SIZE 32
+#define STR_PATH_SIZE 4096
+#define STR_FILE_NAME_SIZE 256
+#define STR_IP_SIZE 64
+
+#endif
diff --git a/src/textFile.c b/src/base/textFile.c
index b3c0156..5c8c95d 100755
--- a/src/textFile.c
+++ b/src/base/textFile.c
@@ -6,9 +6,8 @@
#include <assert.h>
#include <unistd.h>
-#include "main.h"
-#include "textFile.h"
-#include "string_length.h"
+#include "base/main.h"
+#include "base/textFile.h"
textFile_t* newTextFile(char *s)
{
diff --git a/src/base/textFile.h b/src/base/textFile.h
new file mode 100755
index 0000000..ea15b4d
--- /dev/null
+++ b/src/base/textFile.h
@@ -0,0 +1,21 @@
+
+#ifndef TEXTFILE_H
+
+#define TEXTFILE_H
+
+#include "base/list.h"
+
+typedef struct str_textFile_t
+{
+ char *file;
+ list_t *text;
+} textFile_t;
+
+extern textFile_t* newTextFile(char *s);
+extern textFile_t* loadTextFile(char *s);
+extern void printTextFile(textFile_t *p);
+extern void saveTextFile(textFile_t *p);
+extern void destroyTextFile(textFile_t *p);
+
+
+#endif
diff --git a/src/tux.c b/src/base/tux.c
index ea083de..0c0717c 100644
--- a/src/tux.c
+++ b/src/base/tux.c
@@ -4,30 +4,31 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "tux.h"
-#include "arena.h"
-#include "shot.h"
-#include "gun.h"
-#include "item.h"
-#include "arena.h"
-#include "myTimer.h"
-#include "net_multiplayer.h"
-#include "proto.h"
-#include "modules.h"
-#include "idManager.h"
+#include "base/main.h"
+#include "base/tux.h"
+#include "base/arena.h"
+#include "base/shot.h"
+#include "base/gun.h"
+#include "base/item.h"
+#include "base/arena.h"
+#include "base/myTimer.h"
+#include "base/net_multiplayer.h"
+#include "base/proto.h"
+#include "base/modules.h"
+#include "base/idManager.h"
#ifndef PUBLIC_SERVER
-#include "image.h"
-#include "sound.h"
-#include "fake_audio.h"
-#include "layer.h"
-#include "screen_world.h"
-#include "term.h"
+#include "client/image.h"
+#include "client/layer.h"
+#include "client/term.h"
+
+#include "audio/sound.h"
+
+#include "screen/screen_world.h"
#endif
#ifdef PUBLIC_SERVER
-#include "publicServer.h"
+#include "server/publicServer.h"
#endif
#ifndef PUBLIC_SERVER
@@ -315,7 +316,9 @@ void eventTuxIsDead(tux_t *tux)
#ifndef PUBLIC_SERVER
sprintf(msg, "tux with id %d is dead\n", tux->id);
+#ifndef NO_SOUND
playSound("dead", SOUND_GROUP_BASE);
+#endif
appendTextInTerm(msg);
#endif
@@ -375,7 +378,9 @@ void tuxTeleport(tux_t *tux)
#ifndef PUBLIC_SERVER
sprintf(msg, "tux with id %d teleporting\n", tux->id);
+#ifndef NO_SOUND
playSound("teleport", SOUND_GROUP_BASE);
+#endif
appendTextInTerm(msg);
#endif
@@ -563,7 +568,9 @@ void switchTuxGun(tux_t *tux)
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanSwitchGun,
newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("switch_gun", SOUND_GROUP_BASE);
+#endif
sprintf(msg, "tux with id %d switch gun\n", tux->id);
appendTextInTerm(msg);
#endif
@@ -581,7 +588,9 @@ void switchTuxGun(tux_t *tux)
newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("switch_gun", SOUND_GROUP_BASE);
+#endif
sprintf(msg, "tux with id %d switch gun\n", tux->id);
appendTextInTerm(msg);
#endif
@@ -601,7 +610,7 @@ void shotTux(tux_t *tux)
return;
}
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
playSound("switch_gun", SOUND_GROUP_BASE);
#endif
@@ -659,7 +668,9 @@ static void pickUpGun(tux_t *tux)
{
#ifndef PUBLIC_SERVER
char msg[STR_SIZE];
+#ifndef NO_SOUND
playSound("switch_gun", SOUND_GROUP_BASE);
+#endif
sprintf(msg, "tux with id %d pickup\n", tux->id);
appendTextInTerm(msg);
#endif
diff --git a/src/base/tux.h b/src/base/tux.h
new file mode 100644
index 0000000..8a39cf9
--- /dev/null
+++ b/src/base/tux.h
@@ -0,0 +1,137 @@
+
+#ifndef TUX_H
+
+#define TUX_H
+
+#include "base/main.h"
+#include "base/list.h"
+#include "base/arena.h"
+
+#define TUX_STEP 7
+#define TUX_LAYER 0
+
+#define TUX_MAX_ANIMATION_FRAME 10
+#define TUX_KEY 1
+
+#define TUX_LOCATE_UNKNOWN -100
+
+#define TUX_MAX_PICKUP 50
+#define TUX_MAX_BONUS 500
+
+#define TUX_TIME_SPAWN 2000
+#define TUX_TIME_CAN_SHOT 500
+#define TUX_TIME_CAN_SWITCH_GUN 100
+
+#define TUX_STATUS_ALIVE 0
+#define TUX_STATUS_DEAD 1
+#define TUX_STATUS_PAUZED 2
+
+#define TUX_CONTROL_NONE 0
+#define TUX_CONTROL_KEYBOARD_LEFT 1
+#define TUX_CONTROL_KEYBOARD_RIGHT 2
+#define TUX_CONTROL_NET 3
+#define TUX_CONTROL_AI 4
+
+#define TUX_WIDTH 30
+#define TUX_HEIGHT 30
+
+#define TUX_IMG_WIDTH 40
+#define TUX_IMG_HEIGHT 54
+
+#define TUX_UP 8
+#define TUX_LEFT 4
+#define TUX_RIGHT 6
+#define TUX_DOWN 2
+#define POSITION_UNKNOWN -1
+
+#define TUX_SHOT 5
+#define TUX_SWITCH_GUN 0
+
+
+#define GUN_NONE -1
+
+#define GUN_COUNT 7
+#define GUN_MAX_SHOT 5
+
+#define BONUS_COUNT 6
+#define ITEM_COUNT 16
+
+
+#define SHOT_CHECK_AREA 25
+
+#define GUN_SIMPLE 0
+#define GUN_DUAL_SIMPLE 1
+#define GUN_SCATTER 2
+#define GUN_TOMMY 3
+#define GUN_LASSER 4
+#define GUN_MINE 5
+#define GUN_BOMBBALL 6
+
+#define ITEM_MINE 7
+#define ITEM_EXPLOSION 8
+#define ITEM_BIG_EXPLOSION 9
+
+#define BONUS_NONE -1
+#define BONUS_SPEED 10
+#define BONUS_SHOT 11
+#define BONUS_TELEPORT 12
+#define BONUS_GHOST 13
+#define BONUS_4X 14
+#define BONUS_HIDDEN 15
+
+typedef struct tux_struct
+{
+ int id;
+
+ int x;
+ int y;
+
+ char name[STR_NAME_SIZE];
+
+ int status;
+ int control;
+ int position;
+ int score;
+
+ int gun;
+ int shot[GUN_COUNT];
+ int round;
+ int bonus;
+
+ int bonus_time;
+ int pickup_time;
+
+ bool_t isCanShot;
+ bool_t isCanSwitchGun;
+
+ int frame;
+
+ void *client;
+} tux_t;
+
+extern bool_t isTuxInicialized();
+extern void initTux();
+extern tux_t* newTux();
+extern bool_t isTuxAnyGun(tux_t *tux);
+extern void getCourse(int n, int *x, int *y);
+extern void drawTux(tux_t *tux);
+extern void drawListTux(list_t *listTux);
+extern void eventTuxIsDead(tux_t *tux);
+extern tux_t* isConflictWithListTux(list_t *listTux, int x, int y, int w, int h);
+extern int isConflictTuxWithListTux(tux_t *tux, list_t *listTux);
+extern void eventConflictTuxWithShot(arena_t *arena);
+extern void eventConflictTuxWithTeleport(list_t *listTux, list_t *listTeleport);
+extern void tuxTeleport(tux_t *tux);
+extern void actionTux(tux_t *tux, int action);
+extern void eventListTux(list_t *listTux);
+extern tux_t* getTuxID(list_t *listTux, int id);
+extern void getTuxProportion(tux_t *tux, int *x,int *y, int *w, int *h);
+extern void replaceTuxID(tux_t *tux, int id);
+extern int isTuxSeesTux(tux_t *tux, tux_t *thisTux);
+extern void setTuxProportion(tux_t *tux, int x, int y);
+extern void getStatusTux(void *p, int *id, int *x,int *y, int *w, int *h);
+extern void setStatusTux(void *p, int x, int y, int w, int h);
+extern void destroyTux(tux_t *tux);
+extern void quitTux();
+
+#endif
diff --git a/src/buffer.c b/src/buffer.c
deleted file mode 100755
index 37cbdfc..0000000
--- a/src/buffer.c
+++ /dev/null
@@ -1,121 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "main.h"
-#include "buffer.h"
-
-buffer_t * newBuffer(int n)
-{
- buffer_t *new;
-
- new = malloc(sizeof(buffer_t));
- memset(new, 0, sizeof(buffer_t));
- new->alloc = n;
- new->data = malloc(n);
- memset(new->data , 0, n);
-
- return new;
-}
-
-int addBuffer(buffer_t *p, char *data, int len)
-{
- assert( p != NULL );
- assert( data != NULL );
- assert( len >= 0 );
-
- if( p->size + len <= p->alloc )
- {
- memcpy(p->data + p->size, data, len);
- p->size += len;
- return 0;
- }
-
- return 1;
-}
-
-int cutBuffer(buffer_t *p, int len)
-{
- assert( p != NULL );
- assert( len >= 0 );
-
- if( p->size - len >= 0 )
- {
- memmove(p->data, p->data + len, p->size - len);
- p->size -= len;
- return 0;
- }
-
- return 1;
-}
-
-int getBufferLine(buffer_t *p, char *line, int len)
-{
- char *end;
- int ret_len;
-
- assert( p != NULL );
- assert( line != NULL );
- assert( len >= 0 );
-
- end = NULL;
-
- end = memchr(p->data, '\n', p->size);
-
- if( end == NULL ) return -1;
-
- ret_len = (int) ( (end - p->data) + 1);
- if( ret_len > len-1 ) ret_len = len-1;
-
- memset(line, 0, len);
- memcpy(line, p->data, ret_len);
-
- cutBuffer(p, ret_len);
-
- return ret_len;
-}
-
-int getData(buffer_t *p, char *line, int len)
-{
- assert( p != NULL );
- assert( line != NULL );
- assert( len >= 0 );
-
- if( p->size < len)return -1;
- memcpy(line, p->data, len);
- cutBuffer(p, len);
- return len;
-}
-
-void destroyBuffer(buffer_t *p)
-{
- assert( p != NULL );
-
- if( p->data != NULL )free(p->data);
- free(p);
-}
-
-/*
-int main()
-{
- buffer_t *p;
- char str[64];
- char *s[] = {"hello world\n", "dalsi riadok\n", "koniec\n", NULL};
- int i;
-
- p = newBuffer(1024 * 10);
-
- for( i = 0 ; s[i] != NULL ; i++)
- addBuffer(p, s[i], strlen(s[i]));
-
- while( getBufferLine(p, str, 64) > 0 )
- {
- printf("str = %s\n", str);
- }
-
- destroyBuffer(p);
- return 0;
-}
-*/
diff --git a/src/client/Makefile b/src/client/Makefile
new file mode 100644
index 0000000..c5637ea
--- /dev/null
+++ b/src/client/Makefile
@@ -0,0 +1,36 @@
+
+
+all: client.o configFile.o font.o game.o image.o interface.o keytable.o language.o layer.o panel.o screen.o term.o
+
+client.o: client.c client.h
+ $(CC) $(CFLAGS) -o client.o -c client.c
+
+configFile.o: configFile.c configFile.h
+ $(CC) $(CFLAGS) -o configFile.o -c configFile.c
+
+font.o: font.c font.h
+ $(CC) $(CFLAGS) -o font.o -c font.c
+
+game.o: game.c game.h
+ $(CC) $(CFLAGS) -o game.o -c game.c
+
+image.o: image.c image.h
+ $(CC) $(CFLAGS) -o image.o -c image.c
+
+interface.o: interface.c interface.h
+ $(CC) $(CFLAGS) -o interface.o -c interface.c
+
+layer.o: layer.c layer.h
+ $(CC) $(CFLAGS) -o layer.o -c layer.c
+
+panel.o: panel.c panel.h
+ $(CC) $(CFLAGS) -o panel.o -c panel.c
+
+screen.o: screen.c screen.h
+ $(CC) $(CFLAGS) -o screen.o -c screen.c
+
+term.o: term.c term.h
+ $(CC) $(CFLAGS) -o term.o -c term.c
+
+clean:
+ rm -rf *.o
diff --git a/src/client.c b/src/client/client.c
index f49fefb..975c9da 100644
--- a/src/client.c
+++ b/src/client/client.c
@@ -10,27 +10,26 @@
#include <sys/socket.h>
#include <sys/select.h>
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "network.h"
-#include "buffer.h"
-#include "net_multiplayer.h"
-#include "screen_world.h"
-#include "proto.h"
-#include "client.h"
-#include "language.h"
-#include "screen_analyze.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/proto.h"
+
+#include "client/client.h"
+#include "client/language.h"
+
+#include "screen/screen_analyze.h"
+#include "screen/screen_world.h"
static int protocolType;
#ifdef SUPPORT_NET_UNIX_UDP
-#include "udp.h"
+#include "net_unix/udp.h"
static sock_udp_t *sock_server_udp;
#endif
#ifdef SUPPORT_NET_SDL_UDP
-#include "sdl_udp.h"
+#include "net_sdl/sdl_udp.h"
static sock_sdl_udp_t *sock_server_sdl_udp;
#endif
diff --git a/src/client/client.h b/src/client/client.h
new file mode 100644
index 0000000..639f924
--- /dev/null
+++ b/src/client/client.h
@@ -0,0 +1,35 @@
+
+#ifndef MY_CLIENT
+
+#define MY_CLIENT
+
+#include "base/main.h"
+
+#if defined SUPPORT_NET_UNIX_UDP || defined SUPPORT_NET_SDL_UDP
+
+#define CLIENT_TIMEOUT 1000
+#define SERVER_TIMEOUT_ALIVE 5000
+
+#endif
+
+#ifdef SUPPORT_NET_UNIX_UDP
+extern int initUdpClient(char *ip, int port, int proto);
+extern void eventPingServer();
+extern void selectClientUdpSocket();
+extern void refreshPingServerAlive();
+extern void quitUdpClient();
+#endif
+
+#ifdef SUPPORT_NET_SDL_UDP
+extern int initSdlUdpClient(char *ip, int port);
+extern void eventPingServer();
+extern void selectClientSdlUdpSocket();
+extern void refreshPingServerAlive();
+extern bool_t isServerAlive();
+extern void quitSdlUdpClient();
+#endif
+
+extern void sendServer(char *msg);
+extern void eventServerBuffer();
+
+#endif
diff --git a/src/configFile.c b/src/client/configFile.c
index 1c19e3f..acf7a1f 100644
--- a/src/configFile.c
+++ b/src/client/configFile.c
@@ -4,8 +4,8 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "configFile.h"
+#include "base/main.h"
+#include "client/configFile.h"
int isYesOrNO(char *s)
{
diff --git a/src/client/configFile.h b/src/client/configFile.h
new file mode 100644
index 0000000..67898e9
--- /dev/null
+++ b/src/client/configFile.h
@@ -0,0 +1,20 @@
+
+#ifndef CONFIGFILE_H
+
+#define CONFIGFILE_H
+
+#include "base/main.h"
+#include "base/textFile.h"
+
+extern int isYesOrNO(char *s);
+extern char* getYesOrNo(int n);
+
+extern int getValue(char *line, char *env, char *val, int len);
+extern char* setValue(char *line, char *env, char *val);
+
+extern int getValueInConfigFile(textFile_t *textFile, char *env, char *val, int len);
+extern int setValueInConfigFile(textFile_t *textFile, char *env, char *val);
+
+extern void loadValueFromConfigFile(textFile_t *textFile, char *env, char *val, int len, char *butVal);
+
+#endif
diff --git a/src/font.c b/src/client/font.c
index 0f1c200..91d15bb 100755
--- a/src/font.c
+++ b/src/client/font.c
@@ -1,9 +1,7 @@
-#include "main.h"
-#include "interface.h"
-#include "string_length.h"
-#include "font.h"
-#include "path.h"
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/font.h"
static TTF_Font *g_font;
static int fontSize;
diff --git a/src/client/font.h b/src/client/font.h
new file mode 100755
index 0000000..50b1494
--- /dev/null
+++ b/src/client/font.h
@@ -0,0 +1,26 @@
+
+#ifndef FONT_H
+
+#define FONT_H
+
+#include <SDL_ttf.h>
+#include <assert.h>
+#include "base/main.h"
+
+#define COLOR_WHITE 255, 255, 255
+#define COLOR_BLACK 0, 0, 0
+
+#define COLOR_RED 255, 0, 0
+#define COLOR_GREEN 0, 255, 0
+#define COLOR_BLUE 0, 0, 255
+
+#define COLOR_YELLOW 255, 255, 0
+
+extern bool_t isFontInicialized();
+extern void initFont(char *file,int size);
+extern void drawFont(char *s,int x,int y,int r,int g,int b);
+extern int getFontSize();
+extern void getTextSize(char *s, int *w, int *h);
+extern void quitFont();
+
+#endif
diff --git a/src/game.c b/src/client/game.c
index 0c4903f..9ea50ab 100644
--- a/src/game.c
+++ b/src/client/game.c
@@ -8,33 +8,34 @@
#include <assert.h>
#include <sys/stat.h>
-#include "main.h"
-#include "tux.h"
-
-#include "font.h"
-#include "keytable.h"
-#include "language.h"
-#include "image.h"
-#include "layer.h"
-#include "interface.h"
-#include "screen.h"
-#include "screen_world.h"
-#include "screen_mainMenu.h"
-#include "screen_analyze.h"
-#include "screen_setting.h"
-#include "screen_gameType.h"
-#include "screen_choiceArena.h"
-#include "screen_table.h"
-#include "screen_credits.h"
-#include "homeDirector.h"
-#include "item.h"
-#include "shot.h"
-#include "arenaFile.h"
-#include "panel.h"
-#include "audio.h"
-#include "sound.h"
-#include "music.h"
-#include "fake_audio.h"
+#include "base/main.h"
+#include "base/tux.h"
+#include "base/homeDirector.h"
+#include "base/item.h"
+#include "base/shot.h"
+#include "base/arenaFile.h"
+
+#include "client/image.h"
+#include "client/layer.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/font.h"
+#include "client/keytable.h"
+#include "client/language.h"
+#include "client/panel.h"
+
+#include "audio/audio.h"
+#include "audio/sound.h"
+#include "audio/music.h"
+
+#include "screen/screen_world.h"
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_analyze.h"
+#include "screen/screen_setting.h"
+#include "screen/screen_gameType.h"
+#include "screen/screen_choiceArena.h"
+#include "screen/screen_table.h"
+#include "screen/screen_credits.h"
static void initGame()
{
@@ -52,9 +53,11 @@ static void initGame()
initFont(getLanguageFont(), getLanguageSize());
initKeyTable();
initImageData();
+#ifndef NO_SOUND
initAudio();
initSound();
initMusic();
+#endif
initScreen();
initArenaFile();
initTux();
@@ -86,9 +89,11 @@ void quitGame()
quitPanel();
quitWorld();
quitImageData();
+#ifndef NO_SOUND
quitSound();
quitMusic();
quitAudio();
+#endif
quitScreenMainMenu();
quitScreenAnalyze();
quitScreenSetting();
diff --git a/src/client/game.h b/src/client/game.h
new file mode 100644
index 0000000..6ce694d
--- /dev/null
+++ b/src/client/game.h
@@ -0,0 +1,9 @@
+
+#ifndef GAME_H
+
+#define GAME_H
+
+extern void quitGame();
+extern void startGame();
+
+#endif
diff --git a/src/image.c b/src/client/image.c
index 733d480..98b2b8b 100755
--- a/src/image.c
+++ b/src/client/image.c
@@ -3,13 +3,12 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-#include "image.h"
-#include "list.h"
-#include "path.h"
-#include "storage.h"
-#include "string_length.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/storage.h"
+
+#include "client/interface.h"
+#include "client/image.h"
static list_t *listStorage;
diff --git a/src/client/image.h b/src/client/image.h
new file mode 100755
index 0000000..5de6345
--- /dev/null
+++ b/src/client/image.h
@@ -0,0 +1,35 @@
+
+#ifndef IMAGE_H
+
+#define IMAGE_H
+
+#include "client/image.h"
+#include "client/interface.h"
+
+#define IMAGE_NO_ALPHA 0
+#define IMAGE_ALPHA 1
+
+#define IMAGE_GROUP_BASE "base"
+#define IMAGE_GROUP_EXTENDSIO "extension"
+#define IMAGE_GROUP_USER "user"
+#define IMAGE_GROUP_OTHER "other"
+
+/*
+typedef struct image_struct
+{
+ char *name;
+ char *group;
+ SDL_Surface *image;
+} image_data_t;
+*/
+
+extern bool_t isImageInicialized();
+extern void initImageData();
+extern SDL_Surface* addImageData(char *file, int alpha, char *name, char *group);
+extern SDL_Surface* getImage(char *group, char *name);
+extern void delImage(char *group, char *name);
+extern void delAllImageInGroup(char *group);
+extern void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h);
+extern void quitImageData();
+
+#endif
diff --git a/src/interface.c b/src/client/interface.c
index 0b3772e..570e3fd 100755
--- a/src/interface.c
+++ b/src/client/interface.c
@@ -1,11 +1,11 @@
#include <stdlib.h>
-#include "main.h"
-#include "interface.h"
-#include "screen.h"
-#include "myTimer.h"
+#include "base/main.h"
+#include "base/myTimer.h"
+#include "client/interface.h"
+#include "client/screen.h"
//povrch okna
static SDL_Surface *screen;
diff --git a/src/client/interface.h b/src/client/interface.h
new file mode 100755
index 0000000..5804676
--- /dev/null
+++ b/src/client/interface.h
@@ -0,0 +1,40 @@
+
+#ifndef INTERFACE_H
+
+#define INTERFACE_H
+
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include <SDL.h>
+#include <SDL_image.h>
+#include <SDL_thread.h>
+#include "base/main.h"
+
+/*
+#include <SDL_net.h>
+*/
+
+#define SDL_SUBSYSTEMS SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_DOUBLEBUF
+
+//napis na okne
+#define WINDOW_TITLE "Tuxanci next generation " TUXANCI_NG_VERSION
+#define WIN_BPP 0
+#define USR_EVT_TIMER 0
+
+//interval pri ktorom sa spusta akcia();
+#define INTERVAL 50
+
+extern bool_t isInterfaceInicialized();
+extern int initSDL();
+extern SDL_Surface* getSDL_Screen();
+extern void getMousePosition(int *x, int *y);
+extern int isMouseClicked();
+extern int isPessAnyKey();
+extern void interfaceRefresh();
+extern void eventSDL();
+extern void quitSDL();
+
+
+#endif
diff --git a/src/keytable.c b/src/client/keytable.c
index db4aa02..67811a7 100644
--- a/src/keytable.c
+++ b/src/client/keytable.c
@@ -4,12 +4,13 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "homeDirector.h"
-#include "textFile.h"
-#include "configFile.h"
-#include "keytable.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/homeDirector.h"
+#include "base/textFile.h"
+
+#include "client/keytable.h"
+#include "client/configFile.h"
static textFile_t *keytableFile;
static textFile_t *keycontrolFile;
diff --git a/src/client/keytable.h b/src/client/keytable.h
new file mode 100644
index 0000000..80ca258
--- /dev/null
+++ b/src/client/keytable.h
@@ -0,0 +1,27 @@
+
+#ifndef KEYTABLE_H
+
+#define KEYTABLE_H
+
+#define KEY_LENGTH 12
+
+#define KEY_TUX_RIGHT_MOVE_UP 0
+#define KEY_TUX_RIGHT_MOVE_RIGHT 1
+#define KEY_TUX_RIGHT_MOVE_LEFT 2
+#define KEY_TUX_RIGHT_MOVE_DOWN 3
+#define KEY_TUX_RIGHT_SHOOT 4
+#define KEY_TUX_RIGHT_SWITCH_WEAPON 5
+#define KEY_TUX_LEFT_MOVE_UP 6
+#define KEY_TUX_LEFT_MOVE_RIGHT 7
+#define KEY_TUX_LEFT_MOVE_LEFT 8
+#define KEY_TUX_LEFT_MOVE_DOWN 9
+#define KEY_TUX_LEFT_SHOOT 10
+#define KEY_TUX_LEFT_SWITCH_WEAPON 11
+
+extern void initKeyTable();
+extern int getKey(int n);
+extern void quitKeyTable();
+
+#endif
+
+
diff --git a/src/language.c b/src/client/language.c
index 06cb9c1..5444253 100644
--- a/src/language.c
+++ b/src/client/language.c
@@ -1,14 +1,16 @@
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "homeDirector.h"
-#include "textFile.h"
-#include "configFile.h"
-#include "language.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/homeDirector.h"
+#include "base/textFile.h"
+
+#include "client/configFile.h"
+#include "client/language.h"
static textFile_t *languageFile;
static char fontFile[STR_FILE_NAME_SIZE];
diff --git a/src/client/language.h b/src/client/language.h
new file mode 100644
index 0000000..23fc1a4
--- /dev/null
+++ b/src/client/language.h
@@ -0,0 +1,12 @@
+
+#ifndef LANGUAGE_H
+
+#define LANGUAGE_H
+
+extern int initLanguage();
+extern char* getMyText(char *key);
+extern char* getLanguageFont();
+extern int getLanguageSize();
+extern void quitLanguage();
+
+#endif
diff --git a/src/layer.c b/src/client/layer.c
index 07ec40f..707184b 100755
--- a/src/layer.c
+++ b/src/client/layer.c
@@ -2,13 +2,15 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-#include "list.h"
-#include "layer.h"
-#include "image.h"
-#include "tux.h"
-#include "screen_world.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+
+#include "client/interface.h"
+#include "client/layer.h"
+#include "client/image.h"
+
+#include "screen/screen_world.h"
static list_t *listLayer;
diff --git a/src/client/layer.h b/src/client/layer.h
new file mode 100755
index 0000000..3564ef8
--- /dev/null
+++ b/src/client/layer.h
@@ -0,0 +1,53 @@
+
+#ifndef MY_LAYER_H
+
+#define MY_LAYER_H
+
+#include "base/main.h"
+
+typedef struct layer_str
+{
+ int x; //suradnice obrazka na obrazovke
+ int y;
+
+ int w; //rozmery obrazka na obrazovke
+ int h;
+
+ int px; //suradnice casti surfrace
+ int py;
+
+ int pw; //rozmeri casti surfrace
+ int ph;
+
+ int layer;
+
+ SDL_Surface *image; //dane surfrace
+} layer_t;
+
+extern bool_t isLayerInicialized();
+extern void initLayer();
+
+/*
+ * Prida obrazok na vykreslenie do zoznamu
+ * *img - ponter na urfrace obrazka
+ * x,y - suradnice kam sa ma obrazok nakreslit
+ * w,h - rozmeri obrazka
+ * px,py - suradnice casti *img z ktorej sa bude obrazok vykreslovat
+ * ph,ph - rozmeri casti obrazka *img z ktorej sa bude obrazok vykreslovat
+ * layer - layer, na ktorej bude obrazok
+ * (0 - pod tuxancami | 1 - na tej istej ako tuxanci | 2 - nad tuxancami)
+ */
+
+extern void addLayer(SDL_Surface *img,
+ int x,int y, int px,int py,
+ int w,int h, int player);
+
+/*
+ * Vykresli zoznam na obrazovku
+ */
+extern void drawLayer();
+extern void drawLayerCenter(int x, int y);
+extern void flushLayer();
+extern void quitLayer();
+
+#endif
diff --git a/src/panel.c b/src/client/panel.c
index 079d753..af9cccb 100644
--- a/src/panel.c
+++ b/src/client/panel.c
@@ -2,14 +2,14 @@
#include <stdio.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-#include "string_length.h"
-#include "image.h"
-#include "list.h"
-#include "font.h"
-#include "tux.h"
-#include "panel.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+
+#include "client/interface.h"
+#include "client/image.h"
+#include "client/panel.h"
+#include "client/font.h"
static SDL_Surface *g_panel;
static SDL_Surface *g_shot;
diff --git a/src/client/panel.h b/src/client/panel.h
new file mode 100644
index 0000000..144ea02
--- /dev/null
+++ b/src/client/panel.h
@@ -0,0 +1,27 @@
+
+#ifndef PANEL_H
+
+#define PANEL_H
+
+#include "base/main.h"
+#include "base/list.h"
+
+#define PANEL_SCORE_LOCATION_X ( WINDOW_SIZE_X / 2 - w / 2 )
+#define PANEL_SCORE_LOCATION_Y ( WINDOW_SIZE_Y - 40 )
+
+#define PANEL_SHOT_WIDTH 4
+#define PANEL_SHOT_HEIGHT 8
+
+#define PANEL_LOCATION_X 0
+#define PANEL_LOCATION_Y (WINDOW_SIZE_Y-g_panel->h)
+
+#define PANEL_SHOT_FILL 0
+#define PANEL_SHOT_EMPTY 1
+#define PANEL_SHOT_LINE 2
+
+extern bool_t isPanelInicialized();
+extern void initPanel();
+extern void drawPanel(list_t *listTux);
+extern void quitPanel();
+
+#endif
diff --git a/src/screen.c b/src/client/screen.c
index 07a30a2..730476e 100644
--- a/src/screen.c
+++ b/src/client/screen.c
@@ -2,11 +2,12 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-#include "screen.h"
-#include "list.h"
-#include "layer.h"
+#include "base/main.h"
+#include "base/list.h"
+
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/layer.h"
static screen_t *currentScreen;
static list_t *listScreen;
diff --git a/src/client/screen.h b/src/client/screen.h
new file mode 100644
index 0000000..8049147
--- /dev/null
+++ b/src/client/screen.h
@@ -0,0 +1,32 @@
+
+#ifndef SCREEN_H
+
+#define SCREEN_H
+
+#include "base/main.h"
+
+typedef struct screen_struct
+{
+ char *name;
+ void (*fce_start)();
+ void (*fce_event)();
+ void (*fce_draw)();
+ void (*fce_stop)();
+} screen_t;
+
+extern bool_t isScreenInicialized();
+
+extern screen_t* newScreen(char *name,
+ void (*fce_start)(), void (*fce_event)(),
+ void (*fce_draw)(), void (*fce_stop)());
+
+extern void destroyScreen(screen_t *p);
+extern void registerScreen(screen_t *p);
+extern void initScreen();
+extern void setScreen(char *name);
+extern char* getScreen();
+extern void drawScreen();
+extern void eventScreen();
+extern void quitScreen();
+
+#endif
diff --git a/src/term.c b/src/client/term.c
index 62dcd8f..3357f0b 100644
--- a/src/term.c
+++ b/src/client/term.c
@@ -2,12 +2,13 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "interface.h"
-#include "font.h"
-#include "term.h"
-#include "myTimer.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/myTimer.h"
+
+#include "client/interface.h"
+#include "client/term.h"
+#include "client/font.h"
typedef struct struct_term_t
{
diff --git a/src/client/term.h b/src/client/term.h
new file mode 100644
index 0000000..548fda6
--- /dev/null
+++ b/src/client/term.h
@@ -0,0 +1,17 @@
+
+#ifndef TERM_H
+
+#define TERM_H
+
+#include "base/main.h"
+
+#define TERM_MAX_LINES 10
+#define TERM_DEL_TEXT_TIMEOUT 2000
+
+extern void initTerm();
+extern void drawTerm();
+extern void eventTerm();
+extern void appendTextInTerm(char *s);
+extern void quitTerm();
+
+#endif
diff --git a/src/hashTable.c b/src/hashTable.c
deleted file mode 100644
index cc67225..0000000
--- a/src/hashTable.c
+++ /dev/null
@@ -1,221 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "hashTable.h"
-
-hashtable_t* newHashTable()
-{
- hashtable_t *new;
-
- new = malloc( sizeof(hashtable_t) );
- memset(new, 0, sizeof(hashtable_t) );
-
- return new;
-}
-
-void addHashTable(hashtable_t *p, char *key, void *item)
-{
- hashtable_t *this;
- hashtable_t *next;
- int len;
- int i;
-
- this = p;
- next = p;
-
- len = strlen(key);
-
- for( i = 0 ; i < len ; i++ )
- {
- //printf("addHashTable key[%d] = %c\n", i , key[i]);
-
- next = this->table[ (int)key[i] ];
-
- if( next == NULL )
- {
- next = newHashTable();
- this->table[ (int)key[i] ] = next;
- }
-
- this = next;
- }
-
- next->data = item;
-}
-
-void addHashTableWithIndex(hashtable_t *p, int index, void *item)
-{
- char str[16];
- sprintf(str, "%d", index);
- addHashTable(p, str, item);
-}
-
-void* getHashTable(hashtable_t *p, char *key)
-{
- hashtable_t *this;
- hashtable_t *next;
- int len;
- int i;
-
- this = p;
- next = p;
-
- len = strlen(key);
-
- for( i = 0 ; i < len ; i++ )
- {
- //printf("getHashTable key[%d] = %c\n", i , key[i]);
-
- next = this->table[ (int)key[i] ];
-
- //printf("next = %p\n", next);
-
- if( next == NULL )
- {
- return NULL;
- }
-
- this = next;
- }
-
- return next->data;
-}
-
-void* getHashTableWithIndex(hashtable_t *p, int index)
-{
- char str[16];
- sprintf(str, "%d", index);
- return getHashTable(p, str);
-}
-
-void delHashTable(hashtable_t *p, char *key)
-{
- hashtable_t *this;
- hashtable_t *next;
- int len;
- int i;
-
- this = p;
- next = p;
-
- len = strlen(key);
-
- for( i = 0 ; i < len ; i++ )
- {
- //printf("getHashTable key[%d] = %c\n", i , key[i]);
-
- next = this->table[ (int)key[i] ];
-
- //printf("next = %p\n", next);
-
- if( next == NULL )
- {
- return;
- }
-
- this = next;
- }
-
- next->data = NULL;
-
-}
-
-void delHashTableWithIndex(hashtable_t *p, int index)
-{
- char str[16];
- sprintf(str, "%d", index);
- delHashTable(p, str);
-}
-
-void delHashTableWithMem(hashtable_t *p, char *key, void *f)
-{
- void (*fce)(void *p);
-
- delHashTable(p, key);
-
- fce = f;
- fce(key);
-}
-
-void delHashTableWithMemWithIndex(hashtable_t *p, int index)
-{
- char str[16];
- sprintf(str, "%d", index);
- delHashTable(p, str);
-}
-
-void destroyHashTable(hashtable_t *p)
-{
- hashtable_t *this;
- hashtable_t *next;
- int i;
-
- this = p;
-
- for( i = 0 ; i < 256 ; i++ )
- {
- next = this->table[i];
-
- if( next != NULL )
- {
- destroyHashTable(next);
- }
- }
-
- free(p);
-}
-
-void destroyHashTableWithMem(hashtable_t *p, void *f)
-{
- void (*fce)(void *p);
- hashtable_t *this;
- hashtable_t *next;
- int i;
-
- this = p;
- fce = f;
-
- for( i = 0 ; i < 256 ; i++ )
- {
- next = this->table[i];
-
- if( next != NULL )
- {
- destroyHashTableWithMem(next, f);
- }
- }
-
- if( p->data != NULL )
- {
- fce(p->data);
- }
-
- free(p);
-}
-
-int test_main(int argc, char **argv)
-{
- hashtable_t *p;
- int max = 10000;
- int i;
-
- p = newHashTable();
-
- for( i = 0 ; i < max ; i++ )
- {
- addHashTableWithIndex(p, i, NULL);
- }
-
- for( i = 0 ; i < max ; i++ )
- {
- printf("%d -> %s\n", i, (char *)getHashTableWithIndex(p, i) );
- }
-
- //printHashTable(p);
-
- destroyHashTableWithMem(p, free);
-
- return 0;
-}
diff --git a/src/listServer.c b/src/listServer.c
deleted file mode 100644
index 30dba93..0000000
--- a/src/listServer.c
+++ /dev/null
@@ -1,277 +0,0 @@
-
-#include <string.h>
-#include <stdio.h>
-#include <time.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <signal.h>
-
-#include "list.h"
-#include "udp.h"
-
-#define STR_MSG_SIZE 512
-#define STR_IP4_SIZE 20
-
-#define LIMIT_REGISTER "100"
-#define LIMIT_TIME "10"
-
-static sock_udp_t *socketServer;
-static sock_udp_t *socketClient;
-static list_t *listClient;
-
-static int limitRegisterGameServer;
-static int limitTime;
-
-typedef struct client_struct
-{
- char *msg;
- char *ip;
- time_t time;
-} client_t;
-
-static int my_argc;
-static char **my_argv;
-
-char* getParam(char *s)
-{
- int i;
- int len;
-
- len = strlen(s);
-
- for( i = 1 ; i < my_argc ; i++ )
- {
- //printf("%s %s\n", s, my_argv[i]);
-
- if( strlen(my_argv[i]) < len )
- {
- continue;
- }
-
- if( strncmp(s, my_argv[i], len) == 0 )
- {
- return strchr(my_argv[i], '=')+1;
- }
- }
-
- return NULL;
-}
-
-char* getParamElse(char *s1, char *s2)
-{
- char *ret;
- ret = getParam(s1);
-
- if( ret == NULL)
- {
- return s2;
- }
-
- return ret;
-}
-
-bool_t isParamFlag(char *s)
-{
- int i;
-
- for( i = 0 ; i < my_argc ; i++ )
- {
- if( strcmp(s, my_argv[i]) == 0 )
- {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-client_t* newClient(char *str_ip, char *msg)
-{
- client_t *new;
-
- new = malloc( sizeof(client_t) );
- memset(new, 0, sizeof(client_t));
- new->ip = strdup(str_ip);
- new->msg = strdup(msg);
- new->time = time(NULL);
-
- return new;
-}
-
-void replaceClient(client_t *p, char *msg)
-{
- assert( p != NULL );
-
- free(p->msg);
- p->msg = strdup(msg);
- p->time = time(NULL);
-}
-
-void destroyClient(client_t *p)
-{
- assert( p != NULL );
-
- free(p->ip);
- free(p->msg);
- free(p);
-}
-
-void cmd_register(sock_udp_t *client, char *msg)
-{
- char str_ip[STR_IP4_SIZE];
- int len;
- int i;
-
- if( listClient->count > limitRegisterGameServer )
- {
- return;
- }
-
- getSockUdpIp(client, str_ip);
-
- len = strlen(msg);
-
- if( msg[len-1] == '\n' )
- {
- msg[len-1] = '\0';
- len--;
- }
-
- for( i = 0 ; i < len ; i++ )
- {
- if( msg[i] < ' ' || msg[i] > '~' )
- {
- msg[i] = '?';
- }
- }
-
- for( i = 0 ; i < listClient->count ; i++ )
- {
- client_t *client;
-
- client = (client_t *)listClient->list[i];
-
- if( strcmp(client->ip, str_ip) == 0 )
- {
- replaceClient(client, msg+9);
- return;
- }
- }
-
- addList(listClient, newClient(str_ip, msg+9) );
-}
-
-void cmd_list(sock_udp_t *socketClient, char *msg)
-{
- time_t currnetTime;
- char *out_msg;
- int len_out_msg;
- int i;
-
- if( listClient->count == 0 )
- {
- writeUdpSocket(socketServer, socketClient, "<|>\n", 4);
- return;
- }
-
- currnetTime = time(NULL);
-
- len_out_msg = listClient->count * STR_MSG_SIZE;
- out_msg = malloc(len_out_msg);
- memset(out_msg, 0, len_out_msg);
-
- len_out_msg--;
-
- for( i = 0 ; i < listClient->count ; i++ )
- {
- client_t *client;
- char line[STR_MSG_SIZE*2];
- int len_new_line;
-
- client = (client_t *)listClient->list[i];
-
- if( currnetTime - client->time > limitTime )
- {
- delListItem(listClient, i, destroyClient);
- i--;
- continue;
- }
-
- sprintf(line, "ip=\"%s\" %s\n", client->ip, client->msg);
- len_new_line = strlen(line);
-
- if( len_out_msg > len_new_line )
- {
- strcat(out_msg, line);
- len_out_msg -= len_new_line;
- }
- else
- {
- break;
- }
- }
-
- if( listClient->count == 0 )
- {
- writeUdpSocket(socketServer, socketClient, "<|>\n", 4);
- free(out_msg);
- return;
- }
-
- writeUdpSocket(socketServer, socketClient, out_msg, strlen(out_msg) );
- free(out_msg);
-}
-
-void my_handler_quit(int n)
-{
- printf("my_handler_quit\n");
-
- destroyListItem(listClient, destroyClient);
- closeUdpSocket(socketServer);
- destroySockUdp(socketClient);
-
- exit(0);
-}
-
-int main(int argc, char **argv)
-{
- my_argc = argc;
- my_argv = argv;
-
- signal(SIGPIPE, SIG_IGN);
- signal(SIGINT, my_handler_quit);
- signal(SIGTERM, my_handler_quit);
- signal(SIGQUIT, my_handler_quit);
-
- listClient = newList();
-
- limitRegisterGameServer = atoi( getParamElse("--limitclient", LIMIT_REGISTER) );
- limitTime = atoi( getParamElse("--limittime", LIMIT_TIME) );
-
- socketServer = bindUdpSocket(
- getParamElse("--ip", "0.0.0.0"),
- atoi(getParamElse("--port", "8400")) );
-
- socketClient = newSockUdp();
-
- for(;;)
- {
- char msg[STR_MSG_SIZE];
-
- memset(msg, 0, STR_MSG_SIZE);
- readUdpSocket(socketServer, socketClient, msg, STR_MSG_SIZE);
-
- if( strncmp(msg, "register", 8) == 0 )
- {
- cmd_register(socketClient, msg);
- }
-
- if( strncmp(msg, "list", 4) == 0 )
- {
- cmd_list(socketClient, msg);
- }
- }
-
- return 0;
-}
diff --git a/src/modules/Makefile b/src/modules/Makefile
new file mode 100755
index 0000000..39e4388
--- /dev/null
+++ b/src/modules/Makefile
@@ -0,0 +1,22 @@
+
+all: modWall.so modPipe.so modTeleport.so modAI.so
+
+modWall.so:
+ gcc $(CFLAGS) -fPIC -c modWall.c -o modWall.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modWall.so modWall.o ../base/list.o ../base/space.o
+
+modPipe.so:
+ gcc $(CFLAGS) -fPIC -c modPipe.c -o modPipe.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modPipe.so modPipe.o ../base/list.o ../base/space.o
+
+modTeleport.so:
+ gcc $(CFLAGS) -fPIC -c modTeleport.c -o modTeleport.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modTeleport.so modTeleport.o ../base/list.o ../base/space.o
+
+modAI.so:
+ gcc $(CFLAGS) -fPIC -c modAI.c -o modAI.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modAI.so modAI.o ../base/list.o ../base/space.o
+
+clean:
+ rm -rf *.o
+ rm -rf *.so
diff --git a/src/modules/modAI.c b/src/modules/modAI.c
new file mode 100755
index 0000000..d3a9f78
--- /dev/null
+++ b/src/modules/modAI.c
@@ -0,0 +1,256 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/modules.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/list.h"
+#include "base/gun.h"
+#include "base/space.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#include "client/image.h"
+#endif
+
+#ifdef PUBLIC_SERVER
+#include "server/publicServer.h"
+#endif
+
+static export_fce_t *export_fce;
+
+static void cmd_ai(char *line)
+{
+}
+
+int init(export_fce_t *p)
+{
+ export_fce = p;
+
+ return 0;
+}
+
+#ifndef PUBLIC_SERVER
+
+int draw(int x, int y, int w, int h)
+{
+ return 0;
+}
+#endif
+
+/////////////////
+
+int colisionAll(tux_t *tux, int px, int py)
+{
+ arena_t *arena;
+ int x, y, w, h;
+
+ arena = export_fce->fce_getCurrentArena();
+
+ export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h);
+ x += px;
+ y += py;
+
+ return export_fce->fce_isFreeSpace(arena, x, y, w, h);
+}
+
+void gotoTux(tux_t *tux, int x, int y, int w, int h)
+{
+ int px = 0,py = 0;
+ int smer = TUX_DOWN;
+
+ if(tux->x > x+w ) px = -TUX_STEP;
+ if(tux->x < x ) px = +TUX_STEP;
+ if(tux->y > y+h ) py = -TUX_STEP;
+ if(tux->y < y ) py = +TUX_STEP;
+
+ if( px != 0 && py !=0 ) px = 0;
+
+ while( colisionAll(tux, px, 0 ) )
+ {
+ px=0;
+ if(py==0) py = +TUX_STEP;
+ goto sem;
+ }
+
+ while( colisionAll(tux, 0, py ) )
+ {
+ py = 0;
+ if( px == 0 ) px = +TUX_STEP;
+ }
+
+ sem:
+ if( px != 0 && py != 0 ) px = 0;
+
+ if( py== -TUX_STEP )smer = TUX_UP;
+ if( px== +TUX_STEP )smer = TUX_RIGHT;
+ if( px== -TUX_STEP )smer = TUX_LEFT;
+ if( py== +TUX_STEP )smer = TUX_DOWN;
+
+ //printf("smer=%d\n",smer);
+ export_fce->fce_actionTux(tux, smer);
+}
+
+void gotoTuxShot(tux_t *tux, int x, int y, int w, int h)
+{
+ if( tux->x > x && tux->x < x+w )
+ {
+ if( tux->y > y+h )tux->position = TUX_UP;
+ if( tux->y < y )tux->position = TUX_DOWN;
+
+ if( colisionAll(tux, 0, 0) == 0 )
+ {
+ if( tux->shot[GUN_SIMPLE] > 0 )tux->gun = GUN_SIMPLE;
+ if( tux->shot[GUN_DUAL_SIMPLE] > 0 )tux->gun = GUN_DUAL_SIMPLE;
+ if( tux->shot[GUN_SCATTER] > 0 )tux->gun = GUN_SCATTER;
+ if( tux->shot[GUN_TOMMY] > 0 )tux->gun = GUN_TOMMY;
+ if( tux->shot[GUN_LASSER] > 0 )tux->gun = GUN_LASSER;
+ if( tux->shot[GUN_BOMBBALL] > 0 )tux->gun = GUN_BOMBBALL;
+
+ export_fce->fce_actionTux(tux, TUX_SHOT);
+ }
+ }
+
+ if( tux->y > y && tux->y < y+h )
+ {
+ if( tux->x > x+w )tux->position=TUX_LEFT;
+ if( tux->x < x )tux->position=TUX_RIGHT;
+
+ if( colisionAll(tux, 0 , 0) == 0 )
+ {
+ if( tux->shot[GUN_SIMPLE] > 0 )tux->gun = GUN_SIMPLE;
+ if( tux->shot[GUN_DUAL_SIMPLE] > 0 )tux->gun = GUN_DUAL_SIMPLE;
+ if( tux->shot[GUN_SCATTER] > 0 )tux->gun = GUN_SCATTER;
+ if( tux->shot[GUN_TOMMY] > 0 )tux->gun = GUN_TOMMY;
+ if( tux->shot[GUN_LASSER] > 0 )tux->gun = GUN_LASSER;
+ if( tux->shot[GUN_BOMBBALL] > 0 )tux->gun = GUN_BOMBBALL;
+
+ export_fce->fce_actionTux(tux, TUX_SHOT);
+ }
+ }
+}
+
+void killTux(tux_t *tux, int active)
+{
+ arena_t *arena;
+ int i;
+
+ arena = export_fce->fce_getCurrentArena();
+
+ for( i = 0 ; i < arena->spaceTux->list->count ; i++ )
+ {
+ tux_t *thisTux;
+
+ thisTux = arena->spaceTux->list->list[i];
+
+ if( thisTux->control != TUX_CONTROL_KEYBOARD_LEFT &&
+ thisTux->status == TUX_STATUS_ALIVE )
+ {
+ gotoTuxShot(tux, thisTux->x, thisTux->y,
+ TUX_WIDTH, TUX_HEIGHT);
+
+ if( active )
+ {
+ gotoTux(tux, thisTux->x, thisTux->y,
+ TUX_WIDTH, TUX_HEIGHT);
+
+ gotoTuxShot(tux, thisTux->x, thisTux->y,
+ TUX_WIDTH, TUX_HEIGHT);
+
+ break;
+ }
+ }
+ }
+}
+
+/////////////////
+
+static void eventTux(tux_t *tux)
+{
+ arena_t *arena;
+ item_t *item;
+
+ arena = export_fce->fce_getCurrentArena();
+
+ killTux(tux, 0);
+
+ item = NULL;
+
+ if( arena->spaceItem->list->count > 0 )
+ {
+ item = (item_t *) arena->spaceItem->list->list[0];
+ }
+
+ if( item != NULL &&
+ item->type != GUN_MINE )
+ {
+ gotoTux(tux, item->x, item->y,
+ item->w, item->h);
+ }
+ else
+ {
+ killTux(tux, 1);
+ }
+}
+
+int event()
+{
+ static my_time_t lastEvent = 0;
+ my_time_t curentTime;
+ arena_t *arena;
+ int countTuxAI;
+ int i;
+
+ if( lastEvent == 0 )
+ {
+ lastEvent = export_fce->fce_getMyTime();
+ }
+
+ curentTime = export_fce->fce_getMyTime();
+
+ if( curentTime - lastEvent < 25 )
+ {
+ return 0;
+ }
+
+ lastEvent = export_fce->fce_getMyTime();
+ //printf("event AI\n");
+
+ arena = export_fce->fce_getCurrentArena();
+ countTuxAI = 0;
+
+ for( i = 0 ; i < arena->spaceTux->list->count ; i++ )
+ {
+ tux_t *thisTux;
+
+ thisTux = arena->spaceTux->list->list[i];
+
+ if( thisTux->control == TUX_CONTROL_AI &&
+ thisTux->status == TUX_STATUS_ALIVE )
+ {
+ eventTux(thisTux);
+ countTuxAI = 0;
+ }
+ }
+
+ return 0;
+}
+
+int isConflict(int x, int y, int w, int h)
+{
+ return 0;
+}
+
+void cmd(char *line)
+{
+ if( strncmp(line, "ai", 2) == 0 )cmd_ai(line);
+}
+
+int destroy()
+{
+ return 0;
+}
diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c
new file mode 100755
index 0000000..77f2c05
--- /dev/null
+++ b/src/modules/modPipe.c
@@ -0,0 +1,453 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/modules.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/list.h"
+#include "base/gun.h"
+#include "base/space.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#include "client/image.h"
+#endif
+
+#ifdef PUBLIC_SERVER
+#include "server/publicServer.h"
+#endif
+
+typedef struct pipe_struct
+{
+ int x; // poloha steny
+ int y;
+
+ int w; // rozmery steny
+ int h;
+
+ int id;
+ int id_out;
+ int position;
+
+ int layer; // vrstva
+
+#ifndef PUBLIC_SERVER
+ SDL_Surface *img; //obrazok
+#endif
+} pipe_t;
+
+static export_fce_t *export_fce;
+
+static list_t *listPipe;
+static space_t *spacePipe;
+
+#ifndef PUBLIC_SERVER
+static pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position, SDL_Surface *img)
+#endif
+
+#ifdef PUBLIC_SERVER
+static pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position)
+#endif
+
+{
+ pipe_t *new;
+
+#ifndef PUBLIC_SERVER
+ assert( img != NULL );
+#endif
+
+ new = malloc( sizeof(pipe_t) );
+ assert( new != NULL );
+
+ new->x = x;
+ new->y = y;
+ new->w = w;
+ new->h = h;
+ new->layer = layer;
+ new->id = id;
+ new->id_out = id_out;
+ new->position = position;
+#ifndef PUBLIC_SERVER
+ new->img = img;
+#endif
+ return new;
+}
+
+static void setStatusPipe(void *p, int x, int y, int w, int h)
+{
+ pipe_t *pipe;
+
+ pipe = p;
+
+ pipe->x = x;
+ pipe->y = y;
+ pipe->w = w;
+ pipe->h = h;
+}
+
+static void getStatusPipe(void *p, int *id, int *x, int *y, int *w, int *h)
+{
+ pipe_t *pipe;
+
+ pipe = p;
+
+ *id = pipe->id;
+ *x = pipe->x;
+ *y = pipe->y;
+ *w = pipe->w;
+ *h = pipe->h;
+}
+
+#ifndef PUBLIC_SERVER
+
+static void drawPipe(pipe_t *p)
+{
+ assert( p != NULL );
+
+ export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
+}
+
+#endif
+
+static void destroyPipe(pipe_t *p)
+{
+ assert( p != NULL );
+ free(p);
+}
+
+
+static void cmd_teleport(char *line)
+{
+ char str_x[STR_NUM_SIZE];
+ char str_y[STR_NUM_SIZE];
+ char str_w[STR_NUM_SIZE];
+ char str_h[STR_NUM_SIZE];
+ char str_id[STR_NUM_SIZE];
+ char str_id_out[STR_NUM_SIZE];
+ char str_position[STR_NUM_SIZE];
+ char str_layer[STR_NUM_SIZE];
+ char str_image[STR_SIZE];
+ pipe_t *new;
+
+ if( export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "id", str_id, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "id_out", str_id_out, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "position", str_position, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0 )return;
+
+#ifndef PUBLIC_SERVER
+ new = newPipe(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h),
+ atoi(str_layer), atoi(str_id), atoi(str_id_out), atoi(str_position),
+ export_fce->fce_getImage(IMAGE_GROUP_USER, str_image) );
+#endif
+
+#ifdef PUBLIC_SERVER
+ new = newPipe(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h),
+ atoi(str_layer), atoi(str_id), atoi(str_id_out), atoi(str_position) );
+#endif
+
+ if( spacePipe == NULL )
+ {
+ spacePipe = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusPipe, setStatusPipe);
+ }
+
+ addObjectToSpace(spacePipe, new);
+}
+
+static int myAbs(int n)
+{
+ return ( n > 0 ? n : -n );
+}
+
+
+static int getSppedShot(shot_t *shot)
+{
+ return ( myAbs(shot->px) > myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py) );
+}
+
+static void transformShot(shot_t *shot, int position)
+{
+ int speed;
+
+ speed = getSppedShot(shot);
+
+ switch( position )
+ {
+ case TUX_UP :
+ shot->px = 0;
+ shot->py = -speed;
+ break;
+
+ case TUX_LEFT :
+ shot->px = -speed;
+ shot->py = 0;
+ break;
+
+ case TUX_RIGHT :
+ shot->px = speed;
+ shot->py = 0;
+ break;
+
+ case TUX_DOWN :
+ shot->px = 0;
+ shot->py = +speed;
+ break;
+ }
+
+ shot->position = position;
+ shot->isCanKillAuthor = TRUE;
+
+ if( shot->gun == GUN_LASSER )
+ {
+ export_fce->fce_transformOnlyLasser(shot);
+ }
+}
+
+static void moveShot(shot_t *shot, int position, int src_x, int src_y,
+ int dist_x, int dist_y, int dist_w, int dist_h)
+{
+ int offset = 0;
+ int new_x, new_y;
+
+ switch( shot->position )
+ {
+ case TUX_UP :
+ case TUX_DOWN :
+ offset = shot->x - src_x;
+ break;
+
+ case TUX_RIGHT :
+ case TUX_LEFT :
+ offset = shot->y - src_y;
+ break;
+ }
+
+ transformShot(shot, position);
+
+ switch( shot->position )
+ {
+ case TUX_UP :
+ new_x = dist_x + offset;
+ new_y = dist_y;
+ break;
+
+ case TUX_LEFT :
+ new_x = dist_x;
+ new_y = dist_y + offset;
+ break;
+
+ case TUX_RIGHT :
+ new_x = dist_x + dist_w;
+ new_y = dist_y + offset;
+ break;
+
+ case TUX_DOWN :
+ new_x = dist_x + offset;
+ new_y = dist_y + dist_h;
+ break;
+ }
+
+ new_y += shot->px;
+ new_y += shot->py;
+
+ moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot, new_x, new_y);
+
+ if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ export_fce->fce_proto_send_shot_server(PROTO_SEND_ALL, NULL, shot);
+ }
+}
+
+static void moveShotFromPipe(shot_t *shot, pipe_t *pipe)
+{
+ pipe_t *distPipe;
+
+ distPipe = getObjectFromSpaceWithID(spacePipe, pipe->id_out);
+
+ if( distPipe == NULL )
+ {
+ fprintf(stderr, "Pipe %d ID not found\n", pipe->id);
+ return;
+ }
+
+ moveShot(shot, distPipe->position, pipe->x, pipe->y,
+ distPipe->x, distPipe->y, distPipe->w, distPipe->h);
+}
+
+int init(export_fce_t *p)
+{
+ export_fce = p;
+
+ listPipe = newList();
+
+ return 0;
+}
+
+#ifndef PUBLIC_SERVER
+
+int draw(int x, int y, int w, int h)
+{
+ pipe_t *thisPipe;
+ int i;
+
+ if( spacePipe == NULL )
+ {
+ return 0;
+ }
+
+ listDoEmpty(listPipe);
+ getObjectFromSpace(spacePipe, x, y, w, h, listPipe);
+ //printSpace(spacePipe);
+
+ for( i = 0 ; i < listPipe->count ; i++ )
+ {
+ thisPipe = (pipe_t *)listPipe->list[i];
+ assert( thisPipe != NULL );
+ drawPipe(thisPipe);
+ }
+
+ return 0;
+}
+#endif
+
+static int negPosition(int n)
+{
+ switch( n )
+ {
+ case TUX_UP :
+ return TUX_DOWN;
+
+ case TUX_LEFT :
+ return TUX_RIGHT;
+
+ case TUX_RIGHT :
+ return TUX_LEFT;
+
+ case TUX_DOWN :
+ return TUX_UP;
+
+ default :
+ assert( ! "premenna n ma zlu hodnotu !" );
+ break;
+ }
+}
+
+int event()
+{
+ pipe_t *thisPipe;
+ arena_t *arena;
+ int i;
+
+ if( spacePipe == NULL )
+ {
+ return 0;
+ }
+
+/*
+ if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT )
+ {
+ return;
+ }
+*/
+ arena = export_fce->fce_getCurrentArena();
+
+ for( i = 0 ; i < arena->spaceShot->list->count ; i++ )
+ {
+ shot_t *thisShot;
+ int j;
+
+ thisShot = (shot_t *) arena->spaceShot->list->list[i];
+ assert( thisShot != NULL );
+
+ listDoEmpty(listPipe);
+ getObjectFromSpace(spacePipe, thisShot->x, thisShot->y, thisShot->w, thisShot->h, listPipe);
+
+ for( j = 0 ; j < listPipe->count ; j++ )
+ {
+ tux_t *author;
+
+ thisPipe = (pipe_t *)listPipe->list[j];
+
+ author = getObjectFromSpaceWithID(arena->spaceTux, thisShot->author_id);
+
+ if( author != NULL &&
+ author->bonus == BONUS_GHOST &&
+ author->bonus_time > 0 )
+ {
+ continue;
+ }
+
+ if( negPosition( thisShot->position ) == thisPipe->position )
+ {
+ //moveShotFromPipe(thisShot, thisPipe, listPipe);
+
+ if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT )
+ {
+ if( thisShot->gun != GUN_BOMBBALL )
+ {
+ delObjectFromSpaceWithObject(export_fce->fce_getCurrentArena()->spaceShot,
+ thisShot, export_fce->fce_destroyShot);
+ //delListItem(arena->listShot, i, export_fce->fce_destroyShot);
+ i--;
+ }
+ }
+ else
+ {
+ moveShotFromPipe(thisShot, thisPipe);
+ }
+
+ }
+ else
+ {
+ if( thisShot->gun == GUN_BOMBBALL &&
+ export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT )
+ {
+ export_fce->fce_boundBombBall(thisShot);
+ continue;
+ }
+ else
+ {
+ delObjectFromSpaceWithObject(export_fce->fce_getCurrentArena()->spaceShot,
+ thisShot, export_fce->fce_destroyShot);
+ i--;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+int isConflict(int x, int y, int w, int h)
+{
+ if( spacePipe == NULL )
+ {
+ return 0;
+ }
+
+ return isConflictWithObjectFromSpace(spacePipe, x, y, w, h);
+}
+
+void cmd(char *line)
+{
+ if( strncmp(line, "pipe", 4) == 0 )cmd_teleport(line);
+}
+
+int destroy()
+{
+ destroySpaceWithObject(spacePipe, destroyPipe);
+ destroyList(listPipe);
+
+ return 0;
+}
diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c
new file mode 100755
index 0000000..724e371
--- /dev/null
+++ b/src/modules/modTeleport.c
@@ -0,0 +1,506 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/modules.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/list.h"
+#include "base/gun.h"
+#include "base/space.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#include "client/image.h"
+#endif
+
+#ifdef PUBLIC_SERVER
+#include "server/publicServer.h"
+#endif
+
+typedef struct teleport_struct
+{
+ int id;
+
+ int x; // poloha steny
+ int y;
+
+ int w; // rozmery steny
+ int h;
+
+ int layer; // vrstva
+
+#ifndef PUBLIC_SERVER
+ SDL_Surface *img; //obrazok
+#endif
+} teleport_t;
+
+static export_fce_t *export_fce;
+
+static space_t *spaceTeleport;
+static list_t *listTeleport;
+
+#ifndef PUBLIC_SERVER
+teleport_t* newTeleport(int x, int y, int w, int h, int layer, SDL_Surface *img)
+#endif
+
+#ifdef PUBLIC_SERVER
+teleport_t* newTeleport(int x, int y, int w, int h, int layer)
+#endif
+{
+ static int last_id = 0;
+
+ teleport_t *new;
+
+#ifndef PUBLIC_SERVER
+ assert( img != NULL );
+#endif
+
+ new = malloc( sizeof(teleport_t) );
+ assert( new != NULL );
+
+ new->id = ++last_id;
+ new->x = x;
+ new->y = y;
+ new->w = w;
+ new->h = h;
+ new->layer = layer;
+#ifndef PUBLIC_SERVER
+ new->img = img;
+#endif
+
+ return new;
+}
+
+static void setStatusTeleport(void *p, int x, int y, int w, int h)
+{
+ teleport_t *teleport;
+
+ teleport = p;
+
+ teleport->x = x;
+ teleport->y = y;
+ teleport->w = w;
+ teleport->h = h;
+}
+
+static void getStatusTeleport(void *p, int *id, int *x, int *y, int *w, int *h)
+{
+ teleport_t *teleport;
+ teleport = p;
+
+ *id = teleport->id;
+ *x = teleport->x;
+ *y = teleport->y;
+ *w = teleport->w;
+ *h = teleport->h;
+}
+
+#ifndef PUBLIC_SERVER
+
+static void drawTeleport(teleport_t *p)
+{
+ assert( p != NULL );
+
+ export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
+}
+
+#endif
+
+static void destroyTeleport(teleport_t *p)
+{
+ assert( p != NULL );
+ free(p);
+}
+
+
+static void cmd_teleport(char *line)
+{
+ char str_x[STR_NUM_SIZE];
+ char str_y[STR_NUM_SIZE];
+ char str_w[STR_NUM_SIZE];
+ char str_h[STR_NUM_SIZE];
+ char str_layer[STR_NUM_SIZE];
+ char str_image[STR_SIZE];
+ teleport_t *new;
+
+ if( export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0 )return;
+
+#ifndef PUBLIC_SERVER
+ new = newTeleport(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h),
+ atoi(str_layer), export_fce->fce_getImage(IMAGE_GROUP_USER, str_image) );
+#endif
+
+#ifdef PUBLIC_SERVER
+ new = newTeleport(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h),
+ atoi(str_layer) );
+#endif
+
+ if( spaceTeleport == NULL )
+ {
+ spaceTeleport = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusTeleport, setStatusTeleport);
+ }
+
+ addObjectToSpace(spaceTeleport, new);
+}
+
+static teleport_t* getRandomTeleportBut(list_t *list, teleport_t *teleport)
+{
+ int x;
+
+ do{
+ x = random() % list->count;
+ }while( list->list[x] == teleport );
+
+ return (teleport_t *) list->list[x];
+}
+
+static int getRandomPosition()
+{
+ switch( random() % 4 )
+ {
+ case 0 :
+ return TUX_UP;
+
+ case 1 :
+ return TUX_LEFT;
+
+ case 2 :
+ return TUX_RIGHT;
+
+ case 3 :
+ return TUX_DOWN;
+ }
+
+ assert( ! "Stupid error ! " );
+}
+
+static void teleportTux(tux_t *tux, teleport_t *teleport)
+{
+ teleport_t *distTeleport;
+ int dist_x, dist_y;
+
+ if( tux->bonus == BONUS_GHOST ||
+ export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT )
+ {
+ return;
+ }
+
+ distTeleport = getRandomTeleportBut(spaceTeleport->list, teleport);
+
+ //export_fce->fce_getTuxProportion(tux, &current_x, &current_y, NULL, NULL);
+
+ switch( tux->position )
+ {
+ case TUX_UP :
+ dist_x = distTeleport->x + distTeleport->w/2;
+ dist_y = distTeleport->y - ( TUX_HEIGHT + 20 );
+ break;
+ case TUX_LEFT :
+ dist_x = distTeleport->x - ( TUX_WIDTH + 20 );
+ dist_y = distTeleport->y + distTeleport->h/2;
+ break;
+
+ case TUX_RIGHT :
+ dist_x = distTeleport->x + distTeleport->w + 20;
+ dist_y = distTeleport->y + distTeleport->h/2;
+ break;
+
+ case TUX_DOWN :
+ dist_x = distTeleport->x + distTeleport->w/2;
+ dist_y = distTeleport->y + distTeleport->h + 20;
+ break;
+
+ default :
+ assert( ! "premenna p->control ma zlu hodnotu !" );
+ break;
+ }
+
+ if( export_fce->fce_isFreeSpace(export_fce->fce_getCurrentArena(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT) )
+ {
+ moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceTux, tux, dist_x, dist_y);
+ //export_fce->fce_setTuxProportion(tux, dist_x, dist_y);
+#ifndef PUBLIC_SERVER
+ //playSound("teleport", SOUND_GROUP_BASE);
+#endif
+ if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ export_fce->fce_proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
+ }
+ }
+}
+
+static int myAbs(int n)
+{
+ return ( n > 0 ? n : -n );
+}
+
+
+static int getSppedShot(shot_t *shot)
+{
+ return ( myAbs(shot->px) > myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py) );
+}
+
+/*
+static void transformOnlyLasser(shot_t *shot)
+{
+ switch( shot->position )
+ {
+ case TUX_RIGHT :
+ case TUX_LEFT :
+ shot->w = GUN_LASSER_HORIZONTAL;
+ shot->h = GUN_SHOT_VERTICAL;
+#ifndef PUBLIC_SERVER
+ shot->img = g_shot_lasserX;
+#endif
+ break;
+ case TUX_UP :
+ case TUX_DOWN :
+ shot->w = GUN_SHOT_VERTICAL;
+ shot->h = GUN_LASSER_HORIZONTAL;
+#ifndef PUBLIC_SERVER
+ shot->img = g_shot_lasserY;
+#endif
+ break;
+ }
+}
+*/
+
+static void transformShot(shot_t *shot, int position)
+{
+ int speed;
+
+ speed = getSppedShot(shot);
+
+ switch( position )
+ {
+ case TUX_UP :
+ shot->px = 0;
+ shot->py = -speed;
+ break;
+
+ case TUX_LEFT :
+ shot->px = -speed;
+ shot->py = 0;
+ break;
+
+ case TUX_RIGHT :
+ shot->px = speed;
+ shot->py = 0;
+ break;
+
+ case TUX_DOWN :
+ shot->px = 0;
+ shot->py = +speed;
+ break;
+ }
+
+ shot->position = position;
+ shot->isCanKillAuthor = TRUE;
+
+ if( shot->gun == GUN_LASSER )
+ {
+ export_fce->fce_transformOnlyLasser(shot);
+ }
+}
+
+static void moveShot(shot_t *shot, int position, int src_x, int src_y,
+ int dist_x, int dist_y, int dist_w, int dist_h)
+{
+ int offset = 0;
+ int new_x, new_y;
+
+ switch( shot->position )
+ {
+ case TUX_UP :
+ case TUX_DOWN :
+ offset = shot->x - src_x;
+ break;
+
+ case TUX_RIGHT :
+ case TUX_LEFT :
+ offset = shot->y - src_y;
+ break;
+ }
+
+ transformShot(shot, position);
+
+ switch( shot->position )
+ {
+ case TUX_UP :
+ new_x = dist_x + offset;
+ new_y = dist_y;
+ break;
+
+ case TUX_LEFT :
+ new_x = dist_x;
+ new_y = dist_y + offset;
+ break;
+
+ case TUX_RIGHT :
+ new_x = dist_x + dist_w;
+ new_y = dist_y + offset;
+ break;
+
+ case TUX_DOWN :
+ new_x = dist_x + offset;
+ new_y = dist_y + dist_h;
+ break;
+ }
+
+ new_y += shot->px;
+ new_y += shot->py;
+
+ moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot, new_x, new_y);
+
+ if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ export_fce->fce_proto_send_shot_server(PROTO_SEND_ALL, NULL, shot);
+ }
+}
+
+static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, list_t *list)
+{
+ teleport_t *distTeleport;
+
+ distTeleport = getRandomTeleportBut(list, teleport);
+
+ moveShot(shot, getRandomPosition(), teleport->x, teleport->y,
+ distTeleport->x, distTeleport->y, distTeleport->w, distTeleport->h);
+}
+
+int init(export_fce_t *p)
+{
+ export_fce = p;
+
+ listTeleport = newList();
+
+ return 0;
+}
+
+#ifndef PUBLIC_SERVER
+int draw(int x, int y, int w, int h)
+{
+ teleport_t *thisTeleport;
+ int i;
+
+ if( spaceTeleport == NULL )
+ {
+ return 0;
+ }
+
+ listDoEmpty(listTeleport);
+ getObjectFromSpace(spaceTeleport, x, y, w, h, listTeleport);
+
+ for( i = 0 ; i < listTeleport->count ; i++ )
+ {
+ thisTeleport = (teleport_t *)listTeleport->list[i];
+ assert( thisTeleport != NULL );
+ drawTeleport(thisTeleport);
+ }
+
+ return 0;
+}
+#endif
+
+int event()
+{
+ teleport_t *thisTeleport;
+ arena_t *arena;
+ int i;
+
+ if( spaceTeleport == NULL )
+ {
+ return 0;
+ }
+
+ if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT )
+ {
+ return 0;
+ }
+
+ arena = export_fce->fce_getCurrentArena();
+
+ for( i = 0 ; i < arena->spaceTux->list->count ; i++ )
+ {
+ tux_t *thisTux;
+ int x, y, w, h;
+ int j;
+
+ thisTux = (tux_t *)arena->spaceTux->list->list[i];
+ export_fce->fce_getTuxProportion(thisTux, &x, &y, &w, &h);
+
+ listDoEmpty(listTeleport);
+ getObjectFromSpace(spaceTeleport, x, y, w, h, listTeleport);
+
+ for( j = 0 ; j < listTeleport->count ; j++ )
+ {
+ thisTeleport = (teleport_t *)listTeleport->list[j];
+ teleportTux(thisTux, thisTeleport);
+ }
+ }
+
+ for( i = 0 ; i < arena->spaceShot->list->count ; i++ )
+ {
+ shot_t *thisShot;
+ int j;
+
+ thisShot = (shot_t *)arena->spaceShot->list->list[i];
+ assert( thisShot != NULL );
+
+ listDoEmpty(listTeleport);
+ getObjectFromSpace(spaceTeleport, thisShot->x, thisShot->y, thisShot->w, thisShot->h, listTeleport);
+
+ for( j = 0 ; j < listTeleport->count ; j++ )
+ {
+ tux_t *author;
+
+ thisTeleport = (teleport_t *)listTeleport->list[j];
+ author = getObjectFromSpaceWithID(arena->spaceTux, thisShot->author_id);
+
+ if( author != NULL &&
+ author->bonus == BONUS_GHOST &&
+ author->bonus_time > 0 )
+ {
+ continue;
+ }
+
+ moveShotFromTeleport(thisShot, thisTeleport, spaceTeleport->list);
+ }
+ }
+
+ return 0;
+}
+
+int isConflict(int x, int y, int w, int h)
+{
+ if( spaceTeleport == NULL )
+ {
+ return 0;
+ }
+
+ return 0;
+}
+
+void cmd(char *line)
+{
+ if( strncmp(line, "teleport", 8) == 0 )cmd_teleport(line);
+}
+
+int destroy()
+{
+ destroySpaceWithObject(spaceTeleport, destroyTeleport);
+ destroyList(listTeleport);
+ return 0;
+}
diff --git a/src/modules/modWall.c b/src/modules/modWall.c
new file mode 100755
index 0000000..c5e01ce
--- /dev/null
+++ b/src/modules/modWall.c
@@ -0,0 +1,331 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "base/main.h"
+#include "base/modules.h"
+#include "base/tux.h"
+#include "base/shot.h"
+#include "base/list.h"
+#include "base/gun.h"
+#include "base/space.h"
+
+#ifndef PUBLIC_SERVER
+#include "client/interface.h"
+#include "client/image.h"
+#endif
+
+#ifdef PUBLIC_SERVER
+#include "server/publicServer.h"
+#endif
+
+typedef struct wall_struct
+{
+ int id;
+
+ int x; // poloha steny
+ int y;
+
+ int w; // rozmery steny
+ int h;
+
+ int img_x; // poloha obrazka
+ int img_y;
+
+ int layer; // vrstva
+
+#ifndef PUBLIC_SERVER
+ SDL_Surface *img; //obrazok
+#endif
+} wall_t;
+
+static export_fce_t *export_fce;
+
+static space_t *spaceWall;
+
+#ifndef PUBLIC_SERVER
+static space_t *spaceImgWall;
+#endif
+
+static list_t *listWall;
+
+#ifndef PUBLIC_SERVER
+wall_t* newWall(int x, int y, int w, int h,
+ int img_x, int img_y, int layer, SDL_Surface *img)
+#endif
+
+#ifdef PUBLIC_SERVER
+wall_t* newWall(int x, int y, int w, int h,
+ int img_x, int img_y, int layer)
+#endif
+{
+ static int last_id = 0;
+ wall_t *new;
+
+#ifndef PUBLIC_SERVER
+ assert( img != NULL );
+#endif
+ new = malloc( sizeof(wall_t) );
+ assert( new != NULL );
+
+ new->id = ++last_id;
+ new->x = x;
+ new->y = y;
+ new->w = w;
+ new->h = h;
+ new->img_x = img_x;
+ new->img_y = img_y;
+ new->layer = layer;
+#ifndef PUBLIC_SERVER
+ new->img = img;
+#endif
+
+ return new;
+}
+
+#ifndef PUBLIC_SERVER
+
+void drawWall(wall_t *p)
+{
+ assert( p != NULL );
+
+ export_fce->fce_addLayer(p->img, p->img_x, p->img_y, 0, 0, p->img->w, p->img->h, p->layer);
+}
+
+void drawListWall(list_t *list)
+{
+ wall_t *thisWall;
+ int i;
+
+ assert( list != NULL );
+
+ for( i = 0 ; i < list->count ; i++ )
+ {
+ thisWall = (wall_t *)list->list[i];
+ assert( thisWall != NULL );
+ drawWall(thisWall);
+ }
+}
+
+#endif
+
+void eventConflictShotWithWall()
+{
+ arena_t *arena;
+ shot_t *thisShot;
+ tux_t *author;
+ int i;
+
+ arena = export_fce->fce_getCurrentArena();
+
+ for( i = 0 ; i < arena->spaceShot->list->count ; i++ )
+ {
+ thisShot = (shot_t *)arena->spaceShot->list->list[i];
+ assert( thisShot != NULL );
+
+ if( isConflictWithObjectFromSpace(spaceWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) )
+ {
+ author = getObjectFromSpaceWithID(
+ export_fce->fce_getCurrentArena()->spaceTux, thisShot->author_id );
+
+ if( author != NULL &&
+ author->bonus == BONUS_GHOST &&
+ author->bonus_time > 0 )
+ {
+ continue;
+ }
+
+ if( thisShot->gun == GUN_BOMBBALL && export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT )
+ {
+ export_fce->fce_boundBombBall(thisShot);
+ continue;
+ }
+
+ delObjectFromSpaceWithObject(export_fce->fce_getCurrentArena()->spaceShot,
+ thisShot, export_fce->fce_destroyShot);
+
+ //delListItem(listShot, i, export_fce->fce_destroyShot);
+ i--;
+ }
+ }
+}
+
+void destroyWall(wall_t *p)
+{
+ assert( p != NULL );
+ free(p);
+}
+
+static void getStatusWall(void *p, int *id, int *x, int *y, int *w, int *h)
+{
+ wall_t *wall;
+
+ wall = p;
+
+ *id = wall->id;
+ *x = wall->x;
+ *y = wall->y;
+ *w = wall->w;
+ *h = wall->h;
+}
+
+static void setStatusWall(void *p, int x, int y, int w, int h)
+{
+ wall_t *wall;
+
+ wall = p;
+
+ wall->x = x;
+ wall->y = y;
+ wall->w = w;
+ wall->h = h;
+}
+
+#ifndef PUBLIC_SERVER
+
+static void getStatusImgWall(void *p, int *id, int *x, int *y, int *w, int *h)
+{
+ wall_t *wall;
+
+ wall = p;
+
+ *id = wall->id;
+ *x = wall->img_x;
+ *y = wall->img_y;
+ *w = wall->img->w;
+ *h = wall->img->h;
+}
+
+static void setStatusImgWall(void *p, int x, int y, int w, int h)
+{
+}
+
+#endif
+
+static void cmd_wall(char *line)
+{
+ char str_x[STR_NUM_SIZE];
+ char str_y[STR_NUM_SIZE];
+ char str_img_x[STR_NUM_SIZE];
+ char str_img_y[STR_NUM_SIZE];
+ char str_w[STR_NUM_SIZE];
+ char str_h[STR_NUM_SIZE];
+ char str_layer[STR_NUM_SIZE];
+ char str_image[STR_SIZE];
+ wall_t *new;
+
+ if( export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "img_x", str_img_x, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "img_y", str_img_y, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 )return;
+ if( export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0 )return;
+
+#ifndef PUBLIC_SERVER
+ new = newWall(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h),
+ atoi(str_img_x), atoi(str_img_y),
+ atoi(str_layer), export_fce->fce_getImage(IMAGE_GROUP_USER, str_image) );
+#endif
+
+#ifdef PUBLIC_SERVER
+ new = newWall(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h),
+ atoi(str_img_x), atoi(str_img_y),
+ atoi(str_layer) );
+#endif
+
+ if( spaceWall == NULL )
+ {
+ spaceWall = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusWall, setStatusWall);
+
+#ifndef PUBLIC_SERVER
+ spaceImgWall = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusImgWall, setStatusImgWall);
+#endif
+ }
+
+ addObjectToSpace(spaceWall, new);
+
+#ifndef PUBLIC_SERVER
+ addObjectToSpace(spaceImgWall, new);
+#endif
+}
+
+int init(export_fce_t *p)
+{
+ export_fce = p;
+ listWall = newList();
+
+ return 0;
+}
+
+#ifndef PUBLIC_SERVER
+
+int draw(int x, int y, int w, int h)
+{
+ wall_t *thisWall;
+ int i;
+
+ if( spaceWall == NULL )
+ {
+ return 0;
+ }
+
+ listDoEmpty(listWall);
+ getObjectFromSpace(spaceImgWall, x, y, w, h, listWall);
+
+ for( i = 0 ; i < listWall->count ; i++ )
+ {
+ thisWall = (wall_t *)listWall->list[i];
+ assert( thisWall != NULL );
+ drawWall(thisWall);
+ }
+
+ //printSpace(spaceWall);
+
+ return 0;
+}
+#endif
+
+
+int event()
+{
+ if( spaceWall == NULL )
+ {
+ return 0;
+ }
+
+ eventConflictShotWithWall(export_fce->fce_getCurrentArena()->spaceShot->list);
+ return 0;
+}
+
+int isConflict(int x, int y, int w, int h)
+{
+ if( spaceWall == NULL )
+ {
+ return 0;
+ }
+
+ return isConflictWithObjectFromSpace(spaceWall, x, y, w, h);
+}
+
+void cmd(char *line)
+{
+ if( strncmp(line, "wall", 4) == 0 )cmd_wall(line);
+}
+
+int destroy()
+{
+ destroySpaceWithObject(spaceWall, destroyWall);
+#ifndef PUBLIC_SERVER
+ destroySpace(spaceImgWall);
+#endif
+ destroyList(listWall);
+ return 0;
+}
diff --git a/src/net_sdl/Makefile b/src/net_sdl/Makefile
new file mode 100644
index 0000000..f0ffb5b
--- /dev/null
+++ b/src/net_sdl/Makefile
@@ -0,0 +1,9 @@
+
+
+all: sdl_udp.o
+
+sdl_udp.o: sdl_udp.c sdl_udp.h
+ $(CC) $(CFLAGS) -o sdl_udp.o -c sdl_udp.c
+
+clean:
+ rm -rf *.o
diff --git a/src/sdl_udp.c b/src/net_sdl/sdl_udp.c
index 175ac6c..f30ba75 100644
--- a/src/sdl_udp.c
+++ b/src/net_sdl/sdl_udp.c
@@ -6,8 +6,8 @@
#include <stdio.h>
#include <assert.h>
-#include "main.h"
-#include "sdl_udp.h"
+#include "base/main.h"
+#include "net_sdl/sdl_udp.h"
#define BUFSIZE 1000
diff --git a/src/net_sdl/sdl_udp.h b/src/net_sdl/sdl_udp.h
new file mode 100644
index 0000000..91a3c71
--- /dev/null
+++ b/src/net_sdl/sdl_udp.h
@@ -0,0 +1,28 @@
+
+#ifndef MY_SDL_UDP
+
+#include <SDL_net.h>
+
+#define MY_SDL_UDP
+
+#define SDL_UDP_SERVER 0
+#define SDL_UDP_CLIENT 1
+
+typedef struct struct_sock_sdl_udp_t
+{
+ int type;
+ UDPsocket sock;
+ IPaddress srvadd;
+ UDPpacket *packet;
+} sock_sdl_udp_t;
+
+sock_sdl_udp_t* newSdlSockUdp();
+void destroySockSdlUdp(sock_sdl_udp_t *p);
+sock_sdl_udp_t* bindSdlUdpSocket(int port);
+sock_sdl_udp_t* connectSdlUdpSocket(char *address, int port);
+int readSdlUdpSocket(sock_sdl_udp_t *src, sock_sdl_udp_t *dst, void *address, int len);
+int writeSdlUdpSocket(sock_sdl_udp_t *src, sock_sdl_udp_t *dst, void *address, int len);
+int getSockSdlUdpPort(sock_sdl_udp_t *p);
+void closeSdlUdpSocket(sock_sdl_udp_t *p);
+
+#endif
diff --git a/src/net_unix/Makefile b/src/net_unix/Makefile
new file mode 100644
index 0000000..648ca88
--- /dev/null
+++ b/src/net_unix/Makefile
@@ -0,0 +1,9 @@
+
+
+all: udp.o
+
+udp.o: udp.c udp.h
+ $(CC) $(CFLAGS) -o udp.o -c udp.c
+
+clean:
+ rm -rf *.o
diff --git a/src/udp.c b/src/net_unix/udp.c
index 545b639..a701d48 100644
--- a/src/udp.c
+++ b/src/net_unix/udp.c
@@ -13,10 +13,12 @@
#include <string.h>
#include <assert.h>
-
#define BUFSIZE 1000
-#include "udp.h"
-#include "main.h"
+
+#include "base/main.h"
+#include "base/net_multiplayer.h"
+
+#include "net_unix/udp.h"
sock_udp_t* newSockUdp(int proto)
{
diff --git a/src/net_unix/udp.h b/src/net_unix/udp.h
new file mode 100644
index 0000000..e5fd648
--- /dev/null
+++ b/src/net_unix/udp.h
@@ -0,0 +1,31 @@
+
+#ifndef MY_UDP
+
+#include <netinet/in.h>
+
+#define MY_UDP
+
+#define SUPPORT_IPv6
+
+typedef struct struct_sock_udp_t
+{
+ int sock;
+ int proto;
+
+#ifdef SUPPORT_IPv6
+ struct sockaddr_in6 sockAddr6;
+#endif
+ struct sockaddr_in sockAddr;
+} sock_udp_t;
+
+extern sock_udp_t* newSockUdp(int proto);
+extern void destroySockUdp(sock_udp_t *p);
+extern sock_udp_t* bindUdpSocket(char *address, int port, int proto);
+extern sock_udp_t* connectUdpSocket(char *address, int port, int proto);
+extern int readUdpSocket(sock_udp_t *src, sock_udp_t *dst, void *address, int len);
+extern int writeUdpSocket(sock_udp_t *src, sock_udp_t *dst, void *address, int len);
+extern void getSockUdpIp(sock_udp_t *p, char *str_ip, int len);
+extern int getSockUdpPort(sock_udp_t *p);
+extern void closeUdpSocket(sock_udp_t *p);
+
+#endif
diff --git a/src/network.c b/src/network.c
deleted file mode 100755
index dee3c73..0000000
--- a/src/network.c
+++ /dev/null
@@ -1,101 +0,0 @@
-
-#include "network.h"
-#include "tcp.h"
-#include "udp.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <assert.h>
-
-int newSocket(int port,const char *ip)
-{
- struct sockaddr_in address;
- int sockfd;
- int len;
-
- assert( port > 0 && port < 65535 );
-
- sockfd = socket(AF_INET, SOCK_STREAM, 0);
-
- if( sockfd < 0 )
- {
- fprintf(stderr, "Nemozem vytvorit sietovy socket\n");
- return -1;
- }
-
- address.sin_family = AF_INET;
-
- if( ip != NULL )
- address.sin_addr.s_addr = inet_addr(ip);
- else
- address.sin_addr.s_addr = htonl(INADDR_ANY);
-
- address.sin_port = htons(port);
-
- len = sizeof(address);
-
- if( ip == NULL )
- {
- if ( bind(sockfd, (struct sockaddr *)&address, len) < 0 )
- {
- fprintf(stderr, "Nemozem obsadit sietovy port %d\n", port);
- return -1;
- }
-
- listen(sockfd, 5);
- }
- else
- {
- if ( connect(sockfd, (struct sockaddr *)&address, len) < 0 )
- {
- fprintf(stderr, "Nemozem sa pripojit na %s %d\n", ip, port);
- return -1;
- }
- }
-
- return sockfd;
-}
-
-int getNewClient(int sockfd)
-{
- struct sockaddr_in client_address;
- int client_sockfd;
- int client_len;
-
- assert( sockfd >= 0 );
-
- client_len = sizeof(client_address);
-
- client_sockfd = accept(sockfd, (struct sockaddr *)&client_address,
- (socklen_t *)&client_len);
-
- //printf("ip = %s\n",inet_ntoa(client_address.sin_addr));
-
- return client_sockfd;
-}
-
-int getNewClientIP(int sockfd,char **str_ip)
-{
- struct sockaddr_in client_address;
- int client_sockfd;
- int client_len;
-
- assert( sockfd >= 0 );
-
- client_len = sizeof(client_address);
-
- client_sockfd = accept(sockfd, (struct sockaddr *)&client_address,
- (socklen_t *)&client_len);
-
- *str_ip = strdup( inet_ntoa(client_address.sin_addr) );
-
- return client_sockfd;
-}
diff --git a/src/screen/Makefile b/src/screen/Makefile
new file mode 100644
index 0000000..41c8ae1
--- /dev/null
+++ b/src/screen/Makefile
@@ -0,0 +1,29 @@
+
+all: screen_analyze.o screen_credits.o screen_gameType.o screen_choiceArena.o screen_mainMenu.o screen_setting.o screen_table.o screen_world.o
+
+screen_analyze.o: screen_analyze.c screen_analyze.h
+ $(CC) $(CFLAGS) -o screen_analyze.o -c screen_analyze.c
+
+screen_credits.o: screen_credits.c screen_credits.h
+ $(CC) $(CFLAGS) -o screen_credits.o -c screen_credits.c
+
+screen_gameType.o: screen_gameType.c screen_gameType.h
+ $(CC) $(CFLAGS) -o screen_gameType.o -c screen_gameType.c
+
+screen_mainMenu.o: screen_mainMenu.c screen_mainMenu.h
+ $(CC) $(CFLAGS) -o screen_mainMenu.o -c screen_mainMenu.c
+
+screen_setting.o: screen_setting.c screen_setting.h
+ $(CC) $(CFLAGS) -o screen_setting.o -c screen_setting.c
+
+screen_table.o: screen_table.c screen_table.h
+ $(CC) $(CFLAGS) -o screen_table.o -c screen_table.c
+
+screen_world.o: screen_world.c screen_world.h
+ $(CC) $(CFLAGS) -o screen_world.o -c screen_world.c
+
+
+clean:
+ rm -rf *.o
+
+
diff --git a/src/screen_analyze.c b/src/screen/screen_analyze.c
index de84679..c1b8258 100644
--- a/src/screen_analyze.c
+++ b/src/screen/screen_analyze.c
@@ -3,19 +3,23 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "music.h"
-#include "fake_audio.h"
-#include "screen_mainMenu.h"
-#include "list.h"
-#include "screen_analyze.h"
-
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
+#include "base/main.h"
+#include "base/list.h"
+
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_analyze.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
static widget_image_t *image_backgorund;
@@ -45,7 +49,9 @@ static void destroyAnalyze(analyze_t *p)
void startScreenAnalyze()
{
+#ifndef NO_SOUND
playMusic("menu", MUSIC_GROUP_BASE);
+#endif
}
void drawScreenAnalyze()
diff --git a/src/screen/screen_analyze.h b/src/screen/screen_analyze.h
new file mode 100644
index 0000000..b6a9875
--- /dev/null
+++ b/src/screen/screen_analyze.h
@@ -0,0 +1,25 @@
+
+#ifndef SCREEN_ANALYZE_H
+
+#define SCREEN_ANALYZE_H
+
+#include "base/main.h"
+
+typedef struct analyze_struct
+{
+ char *name;
+ int score;
+} analyze_t;
+
+extern void startScreenAnalyze();
+extern void drawScreenAnalyze();
+extern void eventScreenAnalyze();
+extern void stopScreenAnalyze();
+extern void restartAnalyze();
+extern void addAnalyze(char *name, int score);
+extern void setMsgToAnalyze(char *msg);
+extern void endAnalyze();
+extern void initScreenAnalyze();
+extern void quitScreenAnalyze();
+
+#endif
diff --git a/src/screen_choiceArena.c b/src/screen/screen_choiceArena.c
index 272ae10..629f1ba 100644
--- a/src/screen_choiceArena.c
+++ b/src/screen/screen_choiceArena.c
@@ -2,23 +2,26 @@
#include <stdio.h>
#include <assert.h>
-#include "main.h"
-#include "language.h"
-#include "interface.h"
-#include "list.h"
-#include "screen.h"
-#include "image.h"
-#include "music.h"
-#include "fake_audio.h"
-
-#include "arenaFile.h"
-#include "screen_mainMenu.h"
-#include "screen_choiceArena.h"
-
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
-#include "widget_buttonimage.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/arenaFile.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_choiceArena.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
+#include "widget/widget_buttonimage.h"
static widget_image_t *image_backgorund;
@@ -30,7 +33,9 @@ static int choiceArenaId;
void startScreenChoiceArena()
{
+#ifndef NO_SOUND
playMusic("menu", MUSIC_GROUP_BASE);
+#endif
}
void drawScreenChoiceArena()
diff --git a/src/screen/screen_choiceArena.h b/src/screen/screen_choiceArena.h
new file mode 100644
index 0000000..0437aa1
--- /dev/null
+++ b/src/screen/screen_choiceArena.h
@@ -0,0 +1,17 @@
+
+#ifndef SCREEN_CHOICE_ARENA
+
+#define SCREEN_CHOICE_ARENA
+
+#include "base/main.h"
+
+#define SCREENSHOT_ARENA_WIDTH 160
+#define SCREENSHOT_ARENA_HEIGHT 107
+
+extern void drawScreenChoiceArena();
+extern void eventScreenChoiceArena();
+extern int getChoiceArenaId();
+extern void initScreenChoiceArena();
+extern void quitScreenChoiceArena();
+
+#endif
diff --git a/src/screen_credits.c b/src/screen/screen_credits.c
index 3416fb5..3f6cf84 100644
--- a/src/screen_credits.c
+++ b/src/screen/screen_credits.c
@@ -2,20 +2,24 @@
#include <stdio.h>
#include <assert.h>
-#include "main.h"
-#include "language.h"
-#include "interface.h"
-#include "list.h"
-#include "textFile.h"
-#include "screen.h"
-#include "image.h"
-#include "music.h"
-#include "fake_audio.h"
-#include "screen_credits.h"
-
-#include "widget_image.h"
-#include "widget_label.h"
-#include "widget_button.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/textFile.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_credits.h"
+
+#include "widget/widget_image.h"
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
static widget_image_t *image_backgorund;
static widget_button_t *button_back;
@@ -25,7 +29,9 @@ static int offset;
void startScreenCredits()
{
+#ifndef NO_SOUND
playMusic("menu", MUSIC_GROUP_BASE);
+#endif
offset = 0;
}
diff --git a/src/screen/screen_credits.h b/src/screen/screen_credits.h
new file mode 100644
index 0000000..2bbce80
--- /dev/null
+++ b/src/screen/screen_credits.h
@@ -0,0 +1,20 @@
+
+#ifndef SCREEN_CREDITS_H
+
+#define SCREEN_CREDITS_H
+
+#define SCREEN_CREDITS_FILE "credits.en"
+
+#define SCREEN_CREDITS_OFFSET_MIN 130
+#define SCREEN_CREDITS_OFFSET_MAX WINDOW_SIZE_Y-120
+#define SCREEN_CREDITS_OFFSET_RESTART -1000
+#define SCREEN_CREDITS_OFFSET_SPEED 2
+
+extern void startScreenCredits();
+extern void drawScreenCredits();
+extern void eventScreenCredits();
+extern void stopScreenCredits();
+extern void initScreenCredits();
+extern void quitScreenCredits();
+
+#endif
diff --git a/src/screen_gameType.c b/src/screen/screen_gameType.c
index 38cdbf8..5545fc1 100644
--- a/src/screen_gameType.c
+++ b/src/screen/screen_gameType.c
@@ -3,26 +3,28 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "language.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "music.h"
-#include "fake_audio.h"
-
-#include "net_multiplayer.h"
-#include "screen_gameType.h"
-#include "list.h"
-#include "screen_setting.h"
-#include "tux.h"
-#include "udp.h"
-
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
-#include "widget_textfield.h"
-#include "widget_check.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/net_multiplayer.h"
+#include "base/tux.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_gameType.h"
+#include "screen/screen_setting.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
+#include "widget/widget_textfield.h"
+#include "widget/widget_check.h"
static widget_image_t *image_backgorund;
@@ -45,7 +47,9 @@ static widget_textfield_t *textfield_port;
void startScreenGameType()
{
+#ifndef NO_SOUND
playMusic("menu", MUSIC_GROUP_BASE);
+#endif
}
void drawScreenGameType()
diff --git a/src/screen/screen_gameType.h b/src/screen/screen_gameType.h
new file mode 100644
index 0000000..93d38ee
--- /dev/null
+++ b/src/screen/screen_gameType.h
@@ -0,0 +1,17 @@
+
+#ifndef SCREEN_GAME_TYPE
+
+#define SCREEN_GAME_TYPE
+
+#include "base/main.h"
+
+extern void drawScreenGameType();
+extern void eventScreenGameType();
+extern void initScreenGameType();
+extern int getSettingGameType();
+extern char* getSettingIP();
+extern int getSettingPort();
+extern int getSettingProto();
+extern void quitScreenGameType();
+
+#endif
diff --git a/src/screen_mainMenu.c b/src/screen/screen_mainMenu.c
index ee295ba..bd3886f 100644
--- a/src/screen_mainMenu.c
+++ b/src/screen/screen_mainMenu.c
@@ -2,23 +2,26 @@
#include <stdio.h>
#include <assert.h>
-#include "main.h"
-#include "game.h"
-#include "interface.h"
-#include "language.h"
-#include "screen.h"
-#include "image.h"
-#include "music.h"
-#include "fake_audio.h"
-
-#include "screen_mainMenu.h"
-#include "screen_setting.h"
-
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_textfield.h"
-#include "widget_check.h"
-#include "widget_image.h"
+#include "base/main.h"
+
+#include "client/game.h"
+#include "client/interface.h"
+#include "client/language.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_setting.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_textfield.h"
+#include "widget/widget_check.h"
+#include "widget/widget_image.h"
static widget_image_t *image_backgorund;
@@ -30,7 +33,9 @@ static widget_button_t *button_end;
void startScreenMainMenu()
{
+#ifndef NO_SOUND
playMusic("menu", MUSIC_GROUP_BASE);
+#endif
}
void drawScreenMainMenu()
@@ -102,7 +107,9 @@ void initScreenMainMenu()
button_credits = newWidgetButton(getMyText("CREDITS"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 350, eventWidget);
button_end = newWidgetButton(getMyText("END"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, 400, eventWidget);
+#ifndef NO_SOUND
addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE);
+#endif
registerScreen( newScreen("mainMenu", startScreenMainMenu, eventScreenMainMenu,
drawScreenMainMenu, stopScreenMainMenu) );
diff --git a/src/screen/screen_mainMenu.h b/src/screen/screen_mainMenu.h
new file mode 100644
index 0000000..c04e65f
--- /dev/null
+++ b/src/screen/screen_mainMenu.h
@@ -0,0 +1,15 @@
+
+#ifndef SCREEN_MIAN_MENU_H
+
+#define SCREEN_MIAN_MENU_H
+
+#include "base/main.h"
+
+extern void startScreenMainMenu();
+extern void drawScreenMainMenu();
+extern void eventScreenMainMenu();
+extern void stopScreenMainMenu();
+extern void initScreenMainMenu();
+extern void quitScreenMainMenu();
+
+#endif
diff --git a/src/screen_setting.c b/src/screen/screen_setting.c
index 5a42135..fd1388d 100644
--- a/src/screen_setting.c
+++ b/src/screen/screen_setting.c
@@ -3,30 +3,33 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "language.h"
-#include "interface.h"
-#include "screen.h"
-#include "image.h"
-#include "music.h"
-#include "sound.h"
-#include "fake_audio.h"
-
-#include "screen_mainMenu.h"
-#include "list.h"
-#include "homeDirector.h"
-#include "screen_setting.h"
-#include "tux.h"
-#include "textFile.h"
-#include "configFile.h"
-#include "director.h"
-
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_image.h"
-#include "widget_textfield.h"
-#include "widget_check.h"
-#include "widget_select.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/textFile.h"
+#include "base/director.h"
+#include "base/homeDirector.h"
+
+#include "client/configFile.h"
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#include "audio/sound.h"
+#endif
+
+#include "screen/screen_mainMenu.h"
+#include "screen/screen_setting.h"
+
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
+#include "widget/widget_image.h"
+#include "widget/widget_textfield.h"
+#include "widget/widget_check.h"
+#include "widget/widget_select.h"
static widget_image_t *image_backgorund;
@@ -72,7 +75,9 @@ static textFile_t *configFile;
void startScreenSetting()
{
+#ifndef NO_SOUND
playMusic("menu", MUSIC_GROUP_BASE);
+#endif
}
void drawScreenSetting()
diff --git a/src/screen/screen_setting.h b/src/screen/screen_setting.h
new file mode 100644
index 0000000..5b0bae3
--- /dev/null
+++ b/src/screen/screen_setting.h
@@ -0,0 +1,20 @@
+
+#ifndef SCREEN_SETTING
+
+#define SCREEN_SETTING
+
+#include "base/main.h"
+
+extern void initScreenSetting();
+extern void drawScreenSetting();
+extern void eventScreenSetting();
+extern void getSettingNameRight(char *s);
+extern void getSettingNameLeft(char *s);
+extern void getSettingCountRound(int *n);
+extern char* getSettingAI();
+extern bool_t isSettingAnyItem();
+extern bool_t isSettingItem(int item);
+extern void quitScreenSetting();
+
+#endif
+
diff --git a/src/screen_table.c b/src/screen/screen_table.c
index 1571489..df1b7d5 100644
--- a/src/screen_table.c
+++ b/src/screen/screen_table.c
@@ -3,22 +3,25 @@
#include <stdlib.h>
#include <assert.h>
-#include "main.h"
-#include "language.h"
-#include "interface.h"
-#include "list.h"
-#include "textFile.h"
-#include "homeDirector.h"
-#include "screen.h"
-#include "image.h"
-#include "music.h"
-#include "fake_audio.h"
-
-#include "screen_table.h"
-
-#include "widget_image.h"
-#include "widget_label.h"
-#include "widget_button.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/textFile.h"
+#include "base/homeDirector.h"
+
+#include "client/language.h"
+#include "client/interface.h"
+#include "client/screen.h"
+#include "client/image.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#endif
+
+#include "screen/screen_table.h"
+
+#include "widget/widget_image.h"
+#include "widget/widget_label.h"
+#include "widget/widget_button.h"
static widget_image_t *image_backgorund;
static widget_button_t *button_back;
@@ -31,7 +34,9 @@ static textFile_t *textFile;
void startScreenTable()
{
+#ifndef NO_SOUND
playMusic("menu", MUSIC_GROUP_BASE);
+#endif
}
void drawScreenTable()
diff --git a/src/screen/screen_table.h b/src/screen/screen_table.h
new file mode 100644
index 0000000..d16cbbb
--- /dev/null
+++ b/src/screen/screen_table.h
@@ -0,0 +1,17 @@
+
+#ifndef SCREEN_TABLE_H
+
+#define SCREEN_TABLE_H
+
+#define SCREEN_TABLE_MAX_PLAYERS 10
+#define SCREEN_TABLE_FILE_HIGHSCORE_NAME "highscore"
+
+extern void startScreenTable();
+extern void drawScreenTable();
+extern void eventScreenTable();
+extern void stopScreenTable();
+extern int addPlayerInHighScore(char *name, int score);
+extern void initScreenTable();
+extern void quitScreenTable();
+
+#endif
diff --git a/src/screen_world.c b/src/screen/screen_world.c
index f889471..296c31f 100644
--- a/src/screen_world.c
+++ b/src/screen/screen_world.c
@@ -1,40 +1,43 @@
+
#include <stdio.h>
#include <assert.h>
-#include "main.h"
-#include "interface.h"
-
-#include "screen.h"
-#include "screen_world.h"
-#include "screen_analyze.h"
-#include "screen_setting.h"
-#include "screen_gameType.h"
-#include "screen_choiceArena.h"
-#include "screen_table.h"
-
-#include "keytable.h"
-#include "list.h"
-#include "layer.h"
-#include "image.h"
-#include "music.h"
-#include "sound.h"
-#include "fake_audio.h"
-#include "tux.h"
-#include "item.h"
-#include "shot.h"
-#include "gun.h"
-#include "panel.h"
-#include "myTimer.h"
-#include "net_multiplayer.h"
-#include "arena.h"
-#include "arenaFile.h"
-#include "proto.h"
-#include "term.h"
-#include "font.h"
-#include "music.h"
-#include "modules.h"
-#include "idManager.h"
-#include "heightScore.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/item.h"
+#include "base/shot.h"
+#include "base/gun.h"
+#include "base/myTimer.h"
+#include "base/net_multiplayer.h"
+#include "base/arena.h"
+#include "base/arenaFile.h"
+#include "base/proto.h"
+#include "base/modules.h"
+#include "base/idManager.h"
+
+#include "client/interface.h"
+#include "client/keytable.h"
+#include "client/layer.h"
+#include "client/image.h"
+//#include "client/heightScore.h"
+#include "client/term.h"
+#include "client/font.h"
+#include "client/panel.h"
+
+#ifndef NO_SOUND
+#include "audio/music.h"
+#include "audio/sound.h"
+#endif
+
+#include "client/screen.h"
+#include "screen/screen_world.h"
+#include "screen/screen_analyze.h"
+#include "screen/screen_setting.h"
+#include "screen/screen_gameType.h"
+#include "screen/screen_choiceArena.h"
+#include "screen/screen_table.h"
+
static arena_t *arena;
static int count;
@@ -67,7 +70,10 @@ void setGameType()
void setWorldArena(int id)
{
arena = getArena(id);
+
+#ifndef NO_SOUND
playMusic(arena->music, MUSIC_GROUP_USER);
+#endif
}
void setMaxCountRound(int n)
@@ -103,12 +109,14 @@ void countRoundInc()
}
count++;
- printf("count %d/%d\n", count, max_count);
+ //printf("count %d/%d\n", count, max_count);
if( count >= max_count )
{
printf("count %d ending\n", count);
+#ifndef NO_SOUND
playSound("end", SOUND_GROUP_BASE);
+#endif
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_endArena, NULL, TIMER_END_ARENA);
}
}
@@ -547,9 +555,14 @@ void stoptWorld()
destroyArena(arena);
}
+#ifndef NO_SOUND
stopMusic();
+#endif
delAllImageInGroup(IMAGE_GROUP_USER);
+
+#ifndef NO_SOUND
delAllMusicInGroup(MUSIC_GROUP_USER);
+#endif
quitModule();
quitTerm();
quitListID();
@@ -565,6 +578,7 @@ void initWorld()
registerScreen( newScreen("world", startWorld, eventWorld, drawWorld, stoptWorld) );
+#ifndef NO_SOUND
addSound("dead.ogg", "dead", SOUND_GROUP_BASE);
addSound("explozion.ogg", "explozion", SOUND_GROUP_BASE);
addSound("gun_lasser.ogg", "gun_lasser", SOUND_GROUP_BASE);
@@ -577,6 +591,7 @@ void initWorld()
addSound("item_gun.ogg", "item_gun", SOUND_GROUP_BASE);
addSound("switch_gun.ogg", "switch_gun", SOUND_GROUP_BASE);
addSound("end.ogg", "end", SOUND_GROUP_BASE);
+#endif
isScreenWorldInit = TRUE;
}
diff --git a/src/screen/screen_world.h b/src/screen/screen_world.h
new file mode 100644
index 0000000..270d144
--- /dev/null
+++ b/src/screen/screen_world.h
@@ -0,0 +1,31 @@
+
+#ifndef SCREEN_WORLD_H
+
+#define SCREEN_WORLD_H
+
+#include "base/main.h"
+#include "base/myTimer.h"
+#include "base/tux.h"
+#include "base/arena.h"
+
+#define TIMER_END_ARENA 5000
+#define WORLD_COUNT_ROUND_UNLIMITED -1
+#define LAG_SERVER_UNKNOWN -1
+
+extern bool_t isScreenWorldInicialized();
+extern void initWorld();
+extern void setWorldArena(int id);
+extern void setLagServer(my_time_t lag);
+extern void countRoundInc();
+extern void setWorldEnd();
+extern void setMaxCountRound(int n);
+extern tux_t* getControlTux(int control_type);
+extern void setControlTux(tux_t *tux, int control_type);
+extern void tuxControl(tux_t *p);
+extern void drawWorld();
+extern void eventWorld();
+extern void startArena();
+extern void stopArena();
+extern void quitWorld();
+
+#endif
diff --git a/src/server/Makefile b/src/server/Makefile
new file mode 100644
index 0000000..41e140e
--- /dev/null
+++ b/src/server/Makefile
@@ -0,0 +1,15 @@
+
+
+all: heightScore.o publicServer.o serverConfigFile.o
+
+heightScore.o: heightScore.c heightScore.h
+ $(CC) $(CFLAGS) -o heightScore.o -c heightScore.c
+
+publicServer.o: publicServer.c publicServer.h
+ $(CC) $(CFLAGS) -o publicServer.o -c publicServer.c
+
+serverConfigFile.o: serverConfigFile.c serverConfigFile.h
+ $(CC) $(CFLAGS) -o serverConfigFile.o -c serverConfigFile.c
+
+clean:
+ rm -rf *.o
diff --git a/src/heightScore.c b/src/server/heightScore.c
index fa7402e..f36dcf7 100644
--- a/src/heightScore.c
+++ b/src/server/heightScore.c
@@ -4,10 +4,10 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "textFile.h"
-#include "heightScore.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/textFile.h"
+#include "server/heightScore.h"
static textFile_t *textFile;
diff --git a/src/server/heightScore.h b/src/server/heightScore.h
new file mode 100644
index 0000000..b1bf7e2
--- /dev/null
+++ b/src/server/heightScore.h
@@ -0,0 +1,13 @@
+
+#ifndef HEIGHT_SCORE_H
+
+#define HEIGHT_SCORE_H
+
+#define HEIGHTSCORE_MAX_PLAYERS 100
+
+extern void initHeightScore(char *file);
+extern int addPlayerInHighScore(char *name, int score);
+extern char* getTableItem(int index);
+extern void quitHeightScore();
+
+#endif
diff --git a/src/logFile.c b/src/server/logFile.c
index 12a4df8..12a4df8 100644
--- a/src/logFile.c
+++ b/src/server/logFile.c
diff --git a/src/server/logFile.h b/src/server/logFile.h
new file mode 100644
index 0000000..12f5606
--- /dev/null
+++ b/src/server/logFile.h
@@ -0,0 +1,18 @@
+
+#ifndef LOGFILE_H
+
+#define LOGFILE_H
+
+#include "main.h"
+
+typedef struct logFile_struct
+{
+ char *name;
+ FILE *file;
+} logFile_t;
+
+extern logFile_t* newLogFile(char *s);
+extern int writeLog(logFile_t *p, char *s);
+extern void destroyLogFile(logFile_t *p);
+
+#endif
diff --git a/src/publicServer.c b/src/server/publicServer.c
index 4253e17..0bd88ac 100644
--- a/src/publicServer.c
+++ b/src/server/publicServer.c
@@ -6,21 +6,22 @@
#include <signal.h>
#include <time.h>
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "idManager.h"
-#include "myTimer.h"
-#include "arena.h"
-#include "item.h"
-#include "shot.h"
-#include "arenaFile.h"
-#include "proto.h"
-#include "publicServer.h"
-#include "net_multiplayer.h"
-#include "serverConfigFile.h"
-#include "heightScore.h"
-#include "modules.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/tux.h"
+#include "base/idManager.h"
+#include "base/myTimer.h"
+#include "base/arena.h"
+#include "base/item.h"
+#include "base/shot.h"
+#include "base/arenaFile.h"
+#include "base/proto.h"
+#include "base/modules.h"
+#include "base/net_multiplayer.h"
+
+#include "server/publicServer.h"
+#include "server/serverConfigFile.h"
+#include "server/heightScore.h"
static int arenaId;
static arena_t *arena;
diff --git a/src/server/publicServer.h b/src/server/publicServer.h
new file mode 100644
index 0000000..111ff9c
--- /dev/null
+++ b/src/server/publicServer.h
@@ -0,0 +1,18 @@
+
+#ifndef PUBLIC_SERVER_H
+
+#define PUBLIC_SERVER_H
+
+#include "base/arena.h"
+
+#define WORLD_COUNT_ROUND_UNLIMITED -1
+
+extern void countRoundInc();
+extern int initPublicServer();
+extern int getChoiceArenaId();
+extern void eventPublicServer();
+extern void my_handler_quit(int n);
+extern void quitPublicServer();
+extern int startPublicServer();
+
+#endif
diff --git a/src/serverConfigFile.c b/src/server/serverConfigFile.c
index 8640333..7f03019 100644
--- a/src/serverConfigFile.c
+++ b/src/server/serverConfigFile.c
@@ -4,10 +4,10 @@
#include <string.h>
#include <assert.h>
-#include "main.h"
-#include "list.h"
-#include "textFile.h"
-#include "serverConfigFile.h"
+#include "base/main.h"
+#include "base/list.h"
+#include "base/textFile.h"
+#include "server/serverConfigFile.h"
static textFile_t *serverTextFile;
diff --git a/src/server/serverConfigFile.h b/src/server/serverConfigFile.h
new file mode 100644
index 0000000..d016807
--- /dev/null
+++ b/src/server/serverConfigFile.h
@@ -0,0 +1,11 @@
+
+
+#ifndef SERVER_CONFIG_FILE_H
+
+#define SERVER_CONFIG_FILE_H
+
+extern void initServerConfigFile();
+extern char* getServerConfigFileValue(char *env, char *s);
+extern void quitServerConfigFile();
+
+#endif
diff --git a/src/tcp.c b/src/tcp.c
deleted file mode 100755
index a80eca8..0000000
--- a/src/tcp.c
+++ /dev/null
@@ -1,235 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <assert.h>
-
-#include "main.h"
-#include "tcp.h"
-
-#define BUFSIZE 1000
-
-sock_tcp_t* newSockTcp()
-{
- sock_tcp_t *new;
-
- new = malloc( sizeof(sock_tcp_t) );
- memset(new, 0, sizeof(sock_tcp_t));
-
- return new;
-}
-
-void destroySockTcp(sock_tcp_t *p)
-{
- assert( p != NULL );
- free(p);
-}
-
-sock_tcp_t* bindTcpSocket(int port)
-{
- sock_tcp_t *new;
- int len;
-
- assert( port > 0 && port < 65535 );
-
- new = newSockTcp();
-
- assert( new != NULL );
-
- new->sock = socket(AF_INET, SOCK_STREAM, 0);
-
- if( new->sock < 0 )
- {
- fprintf(stderr, "Nemozem vytvorit sietovy socket\n");
- destroySockTcp(new);
- return NULL;
- }
-
- new->sockAddr.sin_family = AF_INET;
- new->sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
- new->sockAddr.sin_port = htons(port);
-
- len = sizeof(new->sockAddr);
-
- if ( bind(new->sock, (struct sockaddr *)&new->sockAddr, len) < 0 )
- {
- fprintf(stderr, "Nemozem obsadit sietovy port %d\n", port);
- destroySockTcp(new);
- return NULL;
- }
-
- listen(new->sock, 5);
-
- return new;
-}
-
-sock_tcp_t* getTcpNewClient(sock_tcp_t *p)
-{
- sock_tcp_t *new;
- int client_len;
-
- assert( p != NULL );
- assert( p->sock >= 0 );
-
- new = newSockTcp();
-
- client_len = sizeof(new->sockAddr);
-
- new->sock = accept(p->sock, (struct sockaddr *)&new->sockAddr,
- (socklen_t *)&client_len);
-
- return new;
-}
-
-void getSockTcpIp(sock_tcp_t *p, char *str_ip)
-{
- assert( p != NULL );
- assert( str_ip != NULL );
-
- strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr));
-}
-
-int getSockTcpPort(sock_tcp_t *p)
-{
- assert( p != NULL );
- return htons(p->sockAddr.sin_port);
-}
-
-sock_tcp_t* connectTcpSocket(char *ip, int port)
-{
- sock_tcp_t *new;
- int len;
-
- assert( ip != NULL );
- assert( port > 0 && port < 65535 );
-
- new = newSockTcp();
-
- new->sock = socket(AF_INET, SOCK_STREAM, 0);
-
- if( new->sock < 0 )
- {
- fprintf(stderr, "Nemozem vytvorit sietovy socket\n");
- destroySockTcp(new);
- return NULL;
- }
-
- new->sockAddr.sin_family = AF_INET;
- new->sockAddr.sin_addr.s_addr = inet_addr(ip);
- new->sockAddr.sin_port = htons(port);
-
- len = sizeof(new->sockAddr);
-
- if ( connect(new->sock, (struct sockaddr *)&new->sockAddr, len) < 0 )
- {
- fprintf(stderr, "Nemozem sa pripojit na %s %d\n", ip, port);
- destroySockTcp(new);
- return NULL;
- }
-
- return new;
-}
-
-int readTcpSocket(sock_tcp_t *p, void *address, int len)
-{
- assert( p != NULL );
- assert( address != NULL );
-
- return read(p->sock, address, len);
-}
-
-int writeTcpSocket(sock_tcp_t *p, void *address, int len)
-{
- assert( p != NULL );
- assert( address != NULL );
-
- return write(p->sock, address, len);
-}
-
-void closeTcpSocket(sock_tcp_t *p)
-{
- assert( p != NULL );
-
- close(p->sock);
- destroySockTcp(p);
-}
-
-static int myWait(sock_tcp_t *p)
-{
- fd_set readfds;
- fd_set errorfds;
- struct timeval tv;
- int max_fd;
-
- tv.tv_sec = 1;
- tv.tv_usec = 0;
-
- FD_ZERO(&readfds);
- FD_ZERO(&errorfds);
- max_fd = p->sock;
-
- FD_SET(p->sock, &readfds);
- FD_SET(p->sock, &errorfds);
-
- select(max_fd+1, &readfds, (fd_set *)0, &errorfds, &tv);
-
- if( FD_ISSET(p->sock, &readfds) )
- {
- FD_CLR(p->sock, &readfds);
- return 1;
- }
-
- return 0;
-}
-
-int test_tcp_main(int argc, char **argv)
-{
- sock_tcp_t *sock;
- char buf[BUFSIZE];
- int ret;
-
- if( strcmp(argv[1], "s") == 0 )
- {
- sock_tcp_t *cli;
-
- sock = bindTcpSocket( atoi(argv[2]) );
-
- while(1)
- {
- while( myWait(sock) == 0 )
- ;
-
- cli = getTcpNewClient(sock);
-
- memset(buf, 0, BUFSIZE);
- ret = readTcpSocket(cli, buf, BUFSIZE);
- writeTcpSocket(cli, buf, ret);
-
- closeTcpSocket(cli);
- }
- }
-
- if( strcmp(argv[1], "c") == 0 )
- {
- sock = connectTcpSocket("127.0.0.1", atoi(argv[2]));
-
- strcpy(buf, "Hello world !\n");
- writeTcpSocket(sock, buf, strlen(buf));
-
- memset(buf, 0, BUFSIZE);
- readTcpSocket(sock, buf, BUFSIZE);
-
- printf("buf = %s", buf);
-
- closeTcpSocket(sock);
- }
-
- return 0;
-}
diff --git a/src/tmp b/src/tmp
deleted file mode 100644
index b685a93..0000000
--- a/src/tmp
+++ /dev/null
@@ -1,10 +0,0 @@
-static void proto_recv_init(char *msg)
-{
- char cmd[STR_SIZE];
- tux_t *tux;
-
- tux = newTux();
- sscanf(msg, "%s %d\n", cmd, &tux->id);
- my_tux_id = tux->id;
- addList(listTux, tux);
-} \ No newline at end of file
diff --git a/src/widget/Makefile b/src/widget/Makefile
new file mode 100644
index 0000000..cdb504b
--- /dev/null
+++ b/src/widget/Makefile
@@ -0,0 +1,28 @@
+
+all: widget_button.o widget_buttonimage.o widget_check.o widget_label.o widget_select.o widget_textfield.o widget_image.o
+
+widget_button.o: widget_button.c widget_button.h
+ $(CC) $(CFLAGS) -o widget_button.o -c widget_button.c
+
+widget_buttonimage.o: widget_buttonimage.c widget_buttonimage.h
+ $(CC) $(CFLAGS) -o widget_buttonimage.o -c widget_buttonimage.c
+
+widget_check.o: widget_check.c widget_check.h
+ $(CC) $(CFLAGS) -o widget_check.o -c widget_check.c
+
+widget_image.o: widget_image.c widget_image.h
+ $(CC) $(CFLAGS) -o widget_image.o -c widget_image.c
+
+widget_label.o: widget_label.c widget_label.h
+ $(CC) $(CFLAGS) -o widget_label.o -c widget_label.c
+
+widget_select.o: widget_select.c widget_select.h
+ $(CC) $(CFLAGS) -o widget_select.o -c widget_select.c
+
+widget_textfield.o: widget_textfield.c widget_textfield.h
+ $(CC) $(CFLAGS) -o widget_textfield.o -c widget_textfield.c
+
+clean:
+ rm -rf *.o
+
+
diff --git a/src/widget_button.c b/src/widget/widget_button.c
index 2638619..7f0957b 100644
--- a/src/widget_button.c
+++ b/src/widget/widget_button.c
@@ -1,11 +1,13 @@
#include <stdlib.h>
-#include "main.h"
-#include "interface.h"
-#include "font.h"
+#include "base/main.h"
+
+#include "client/interface.h"
+#include "client/image.h"
+#include "client/font.h"
+
#include "widget_button.h"
-#include "image.h"
widget_button_t* newWidgetButton(char *text, int x, int y, void (*fce_event)(void *))
{
diff --git a/src/widget/widget_button.h b/src/widget/widget_button.h
new file mode 100644
index 0000000..1662407
--- /dev/null
+++ b/src/widget/widget_button.h
@@ -0,0 +1,27 @@
+
+#ifndef WIDGET_BUTTON_H
+
+#define WIDGET_BUTTON_H
+
+#include "base/main.h"
+
+#define WIDGET_BUTTON_TIME 10
+
+#define WIDGET_BUTTON_WIDTH 125
+#define WIDGET_BUTTON_HEIGHT 36
+
+typedef struct widget_button
+{
+ int x, y;
+ int w, h;
+ char *text;
+ void (*fce_event)(void *);
+} widget_button_t;
+
+extern widget_button_t* newWidgetButton(char *text, int x, int y, void (*fce_event)(void *));
+extern void drawWidgetButton(widget_button_t *p);
+extern void eventWidgetButton(widget_button_t *p);
+extern void destroyWidgetButton(widget_button_t *p);
+
+#endif
+
diff --git a/src/widget_buttonimage.c b/src/widget/widget_buttonimage.c
index db7e537..7c59f3b 100644
--- a/src/widget_buttonimage.c
+++ b/src/widget/widget_buttonimage.c
@@ -1,11 +1,10 @@
#include <stdlib.h>
-
-#include "main.h"
-#include "interface.h"
-#include "font.h"
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/font.h"
+#include "client/image.h"
#include "widget_buttonimage.h"
-#include "image.h"
widget_buttonimage_t* newWidgetButtonimage(SDL_Surface *image, int x, int y, void (*fce_event)(void *))
{
diff --git a/src/widget/widget_buttonimage.h b/src/widget/widget_buttonimage.h
new file mode 100644
index 0000000..d30e5bf
--- /dev/null
+++ b/src/widget/widget_buttonimage.h
@@ -0,0 +1,27 @@
+
+#ifndef WIDGET_BUTTONIMAGE_H
+
+#include "base/main.h"
+
+#define WIDGET_BUTTONIMAGE_H
+
+#define WIDGET_BUTTONIMAGE_TIME 10
+
+typedef struct widget_buttonimageimage
+{
+ int x, y;
+ int w, h;
+ int active;
+ SDL_Surface *image;
+ void (*fce_event)(void *);
+} widget_buttonimage_t;
+
+extern widget_buttonimage_t* newWidgetButtonimage(SDL_Surface *image, int x, int y,
+ void (*fce_event)(void *));
+
+extern void drawWidgetButtonimage(widget_buttonimage_t *p);
+extern void eventWidgetButtonimage(widget_buttonimage_t *p);
+extern void destroyWidgetButtonimage(widget_buttonimage_t *p);
+
+#endif
+
diff --git a/src/widget_check.c b/src/widget/widget_check.c
index 0222652..feb2414 100644
--- a/src/widget_check.c
+++ b/src/widget/widget_check.c
@@ -1,10 +1,9 @@
#include <stdlib.h>
-
-#include "main.h"
-#include "interface.h"
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/image.h"
#include "widget_check.h"
-#include "image.h"
widget_check_t* newWidgetCheck(int x, int y, bool_t status, void (*fce_event)(void *))
{
diff --git a/src/widget/widget_check.h b/src/widget/widget_check.h
new file mode 100644
index 0000000..68aecd9
--- /dev/null
+++ b/src/widget/widget_check.h
@@ -0,0 +1,27 @@
+
+#ifndef WIDGET_CHECK_H
+
+#define WIDGET_CHECK_H
+
+#include "base/main.h"
+
+#define WIDGET_CHECK_TIME_SWITCH_STATUS 5
+
+#define WIDGET_CHECK_WIDTH 25
+#define WIDGET_CHECK_HEIGHT 25
+
+typedef struct widget_check
+{
+ int x, y;
+ bool_t status;
+ int time;
+ void (*fce_event)(void *);
+} widget_check_t;
+
+extern widget_check_t* newWidgetCheck(int x, int y, bool_t status, void (*fce_event)(void *));
+extern void drawWidgetCheck(widget_check_t *p);
+extern void eventWidgetCheck(widget_check_t *p);
+extern void destroyWidgetCheck(widget_check_t *p);
+
+#endif
+
diff --git a/src/widget_image.c b/src/widget/widget_image.c
index b3b895e..5e1b743 100644
--- a/src/widget_image.c
+++ b/src/widget/widget_image.c
@@ -1,9 +1,11 @@
#include <stdlib.h>
-#include "main.h"
-#include "interface.h"
-#include "image.h"
+#include <stdlib.h>
+#include "base/main.h"
+#include "client/image.h"
+#include "client/interface.h"
+#include "client/font.h"
#include "widget_image.h"
widget_image_t* newWidgetImage(int x, int y, SDL_Surface *image)
diff --git a/src/widget/widget_image.h b/src/widget/widget_image.h
new file mode 100644
index 0000000..85c98d7
--- /dev/null
+++ b/src/widget/widget_image.h
@@ -0,0 +1,21 @@
+
+#ifndef WIDGET_IMAGE_H
+
+#define WIDGET_IMAGE_H
+
+#include "base/main.h"
+#include "client/interface.h"
+
+typedef struct widget_image
+{
+ int x, y;
+ SDL_Surface *image;
+} widget_image_t;
+
+extern widget_image_t* newWidgetImage(int x, int y, SDL_Surface *image);
+extern void drawWidgetImage(widget_image_t *p);
+extern void eventWidgetImage(widget_image_t *p);
+extern void destroyWidgetImage(widget_image_t *p);
+
+#endif
+
diff --git a/src/widget_label.c b/src/widget/widget_label.c
index 15dea4d..a472784 100644
--- a/src/widget_label.c
+++ b/src/widget/widget_label.c
@@ -1,9 +1,9 @@
#include <stdlib.h>
-#include "main.h"
-#include "interface.h"
-#include "font.h"
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/font.h"
#include "widget_label.h"
widget_label_t* newWidgetLabel(char *text, int x, int y, int bind)
diff --git a/src/widget/widget_label.h b/src/widget/widget_label.h
new file mode 100644
index 0000000..a3bb060
--- /dev/null
+++ b/src/widget/widget_label.h
@@ -0,0 +1,26 @@
+
+#ifndef WIDGET_LABEL_H
+
+#define WIDGET_LABEL_H
+
+#include "base/main.h"
+
+typedef struct widget_label
+{
+ int x, y;
+ int w, h;
+ char *text;
+ int bind;
+} widget_label_t;
+
+#define WIDGET_LABEL_RIGHT 1
+#define WIDGET_LABEL_LEFT 2
+#define WIDGET_LABEL_CENTER 3
+
+extern widget_label_t* newWidgetLabel(char *text, int x, int y, int bind);
+extern void drawWidgetLabel(widget_label_t *p);
+extern void eventWidgetLabel(widget_label_t *p);
+extern void destroyWidgetLabel(widget_label_t *p);
+
+#endif
+
diff --git a/src/widget_select.c b/src/widget/widget_select.c
index dbd6fa9..f51239c 100644
--- a/src/widget_select.c
+++ b/src/widget/widget_select.c
@@ -1,11 +1,9 @@
#include <stdlib.h>
-
-#include "main.h"
-#include "interface.h"
-#include "font.h"
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/font.h"
#include "widget_select.h"
-#include "image.h"
/*
typedef struct widget_select
diff --git a/src/widget/widget_select.h b/src/widget/widget_select.h
new file mode 100644
index 0000000..2765f11
--- /dev/null
+++ b/src/widget/widget_select.h
@@ -0,0 +1,26 @@
+
+#ifndef WIDGET_SELECT_H
+
+#define WIDGET_SELECT_H
+
+#include "base/main.h"
+#include "base/list.h"
+
+
+typedef struct widget_select
+{
+ int x, y;
+ int w, h;
+ list_t *list;
+ int select;
+ void (*fce_event)(void *);
+} widget_select_t;
+
+extern widget_select_t* newWidgetSelect(int x, int y, void (*fce_event)(void *));
+extern void addToWidgetSelect(widget_select_t *p, char *s);
+extern void drawWidgetSelect(widget_select_t *p);
+extern void eventWidgetSelect(widget_select_t *p);
+extern void destroyWidgetSelect(widget_select_t *p);
+
+#endif
+
diff --git a/src/widget_textfield.c b/src/widget/widget_textfield.c
index d61718f..f9186c9 100644
--- a/src/widget_textfield.c
+++ b/src/widget/widget_textfield.c
@@ -1,10 +1,10 @@
-#include <stdlib.h>
-#include "main.h"
-#include "interface.h"
-#include "font.h"
+#include <stdlib.h>
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/font.h"
+#include "client/image.h"
#include "widget_textfield.h"
-#include "image.h"
widget_textfield_t* newWidgetTextfield(char *text, int x, int y)
{
diff --git a/src/widget/widget_textfield.h b/src/widget/widget_textfield.h
new file mode 100644
index 0000000..368f329
--- /dev/null
+++ b/src/widget/widget_textfield.h
@@ -0,0 +1,33 @@
+
+#ifndef WIDGET_TEXTFIELD_H
+
+#define WIDGET_TEXTFIELD_H
+
+#include "base/main.h"
+
+#define WIDGET_TEXTFIELD_WIDTH 188
+#define WIDGET_TEXTFIELD_HEIGHT 36
+
+#define WIDGET_TEXTFIELD_TEXT_OFFSET_X 10
+
+#define WIDGET_TEXTFIELD_TIME_READ_KEY 2
+#define WIDGET_TEXTFIELD_TIME_BLICK_CURSOR 20
+
+typedef struct widget_textfield
+{
+ int x, y;
+ int w, h;
+ int canWrite;
+ int timeBlick;
+ int time;
+ char text[STR_SIZE];
+ bool_t active;
+} widget_textfield_t;
+
+extern widget_textfield_t* newWidgetTextfield(char *text, int x, int y);
+extern void drawWidgetTextfield(widget_textfield_t *p);
+extern void eventWidgetTextfield(widget_textfield_t *p);
+extern void destroyWidgetTextfield(widget_textfield_t *p);
+
+#endif
+
diff --git a/src/zal_pipe.c b/src/zal_pipe.c
deleted file mode 100644
index 65ba6b2..0000000
--- a/src/zal_pipe.c
+++ /dev/null
@@ -1,256 +0,0 @@
-
-#include <stdlib.h>
-#include <assert.h>
-
-#include "pipe.h"
-#include "layer.h"
-#include "screen_world.h"
-#include "shot.h"
-
-pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position, SDL_Surface *img)
-{
- pipe_t *new;
-
- assert( img != NULL );
-
- new = malloc( sizeof(pipe_t) );
- assert( new != NULL );
-
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->layer = layer;
- new->id = id;
- new->id_out = id_out;
- new->position = position;
- new->img = img;
-
- return new;
-}
-
-void drawPipe(pipe_t *p)
-{
- assert( p != NULL );
-
- addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
-}
-
-void drawListPipe(list_t *listPipe)
-{
- pipe_t *thisPipe;
- int i;
-
- assert( listPipe != NULL );
-
- for( i = 0 ; i < listPipe->count ; i++ )
- {
- thisPipe = (pipe_t *)listPipe->list[i];
- assert( thisPipe != NULL );
- drawPipe(thisPipe);
- }
-}
-
-pipe_t* isConflictWithListPipe(list_t *listPipe, int x, int y, int w, int h)
-{
- pipe_t *thisPipe;
- int i;
-
- assert( listPipe != NULL );
-
- for( i = 0 ; i < listPipe->count ; i++ )
- {
- thisPipe = (pipe_t *)listPipe->list[i];
- assert( thisPipe != NULL );
-
- if( conflictSpace(x, y, w, h,
- thisPipe->x, thisPipe->y, thisPipe->w, thisPipe->h) )
- {
- return thisPipe;
- }
- }
-
- return NULL;
-}
-
-static int negPosition(int n)
-{
- switch( n )
- {
- case TUX_UP :
- return TUX_DOWN;
-
- case TUX_LEFT :
- return TUX_RIGHT;
-
- case TUX_RIGHT :
- return TUX_LEFT;
-
- case TUX_DOWN :
- return TUX_UP;
-
- default :
- assert( ! "premenna n ma zlu hodnotu !" );
- break;
- }
-}
-
-static pipe_t* getPipeId(list_t *listPipe, int id)
-{
- int i;
-
- for( i = 0 ; i < listPipe->count ; i++ )
- {
- pipe_t *thisPipe;
-
- thisPipe = (pipe_t *) listPipe->list[i];
-
- if( thisPipe->id == id )
- {
- return thisPipe;
- }
- }
-
- return NULL;
-}
-
-static int myAbs(int n)
-{
- return ( n > 0 ? n : -n );
-}
-
-static int getSppedShot(shot_t *shot)
-{
- return ( myAbs(shot->px) > myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py) );
-}
-
-static void transformShot(shot_t *shot, int position)
-{
- int speed;
-
- speed = getSppedShot(shot);
-
- switch( position )
- {
- case TUX_UP :
- shot->px = 0;
- shot->py = -speed;
- break;
-
- case TUX_LEFT :
- shot->px = -speed;
- shot->py = 0;
- break;
-
- case TUX_RIGHT :
- shot->px = speed;
- shot->py = 0;
- break;
-
- case TUX_DOWN :
- shot->px = 0;
- shot->py = +speed;
- break;
-
- }
-
- shot->position = position;
- shot->isCanKillAuthor = TRUE;
-}
-
-static void moveShot(shot_t *shot, pipe_t *pipe, list_t *listPipe)
-{
- pipe_t *distPipe;
- int offset;
-
- distPipe = getPipeId(listPipe, pipe->id_out);
-
- if( distPipe == NULL )
- {
- fprintf(stderr, "Pipe %d ID not found\n", pipe->id);
- return;
- }
-
- printf("XXX\n");
-
- switch( shot->position )
- {
- case TUX_UP :
- case TUX_DOWN :
- offset = shot->x - pipe->x;
- break;
-
- case TUX_RIGHT :
- case TUX_LEFT :
- offset = shot->y - pipe->y;
- break;
- }
-
- transformShot(shot, distPipe->position);
-
- switch( shot->position )
- {
- case TUX_UP :
- shot->x = distPipe->x + offset;
- shot->y = distPipe->y;
- break;
-
- case TUX_LEFT :
- shot->x = distPipe->x;
- shot->y = distPipe->y + offset;
- break;
-
- case TUX_RIGHT :
- shot->x = distPipe->x + distPipe->w;
- shot->y = distPipe->y + offset;
- break;
-
- case TUX_DOWN :
- shot->x = distPipe->x + offset;
- shot->y = distPipe->y + distPipe->h;
- break;
- }
-}
-
-void eventConflictShotWithPipe(list_t *listPipe, list_t *listShot)
-{
- shot_t *thisShot;
- pipe_t *thisPipe;
- int i;
-
- assert( listPipe != NULL );
- assert( listShot != NULL );
-
- for( i = 0 ; i < listShot->count ; i++ )
- {
- thisShot = (shot_t *)listShot->list[i];
- assert( thisShot != NULL );
-
- if( ( thisPipe = isConflictWithListPipe(listPipe, thisShot->x, thisShot->y,
- thisShot->w, thisShot->h) ) != NULL )
- {
- if( thisShot->author->bonus == BONUS_GHOST &&
- thisShot->author->bonus_time > 0 )
- {
- continue;
- }
-
- if( negPosition( thisShot->position ) == thisPipe->position )
- {
- moveShot(thisShot, thisPipe, listPipe);
- }
- else
- {
- delListItem(listShot, i, destroyShot);
- i--;
- }
- }
- }
-}
-
-void destroyPipe(pipe_t *p)
-{
- assert( p != NULL );
- free(p);
-}
-
diff --git a/src/zal_proto.c b/src/zal_proto.c
deleted file mode 100644
index a091e19..0000000
--- a/src/zal_proto.c
+++ /dev/null
@@ -1,692 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "item.h"
-#include "shot.h"
-#include "arenaFile.h"
-#include "myTimer.h"
-#include "server.h"
-#include "proto.h"
-#include "net_multiplayer.h"
-
-#ifndef PUBLIC_SERVER
-#include "network.h"
-#include "screen_world.h"
-#include "screen_setting.h"
-#include "screen_choiceArena.h"
-#include "client.h"
-#include "term.h"
-#endif
-
-#ifdef PUBLIC_SERVER
-#include "publicServer.h"
-#endif
-
-static void proto_send(int type, client_t *client, char *msg)
-{
- assert( msg != NULL );
-
- switch( type )
- {
- case PROTO_SEND_ONE :
- assert( client != NULL );
- sendClient(client, msg);
-#ifdef DEBUG_SERVER_SEND
- printf("send one client msg->%s\n", msg);
-#endif
- break;
- case PROTO_SEND_ALL :
- assert( client == NULL );
- sendAllClient(msg);
-#ifdef DEBUG_SERVER_SEND
- printf("send all clients msg->%s\n", msg);
-#endif
- break;
- case PROTO_SEND_BUT :
- assert( client != NULL );
- sendAllClientBut(msg, client);
-#ifdef DEBUG_SERVER_SEND
- printf("send but client msg->%s\n", msg);
-#endif
- break;
- default :
- assert( ! "Premenna type ma zlu hodnotu !" );
- break;
- }
-}
-
-void proto_send_error_server(int type, client_t *client, int errorcode)
-{
- char msg[STR_PROTO_SIZE];
-
- sprintf(msg, "error %d\n", errorcode);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_error_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int errorcode;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d",
- cmd, &errorcode);
-
- printf("proto error code %d\n", errorcode);
-}
-
-#endif
-
-#ifndef PUBLIC_SERVER
-
-void proto_send_hello_client(char *name)
-{
- char msg[STR_PROTO_SIZE];
-
- sprintf(msg, "hello %s %s\n", TUXANCI_NG_VERSION, name);
- sendServer(msg);
-}
-
-#endif
-
-void proto_recv_hello_server(client_t *client, char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- char version[STR_NAME_SIZE];
- char name[STR_NAME_SIZE];
-
- assert( client != NULL );
-
- strcpy(version, "");
- strcpy(name, "");
-
- sscanf(msg, "%s %s %s", cmd, version, name);
-
- if( strncmp(version, TUXANCI_NG_VERSION, strlen(TUXANCI_NG_VERSION)) != 0 )
- {
- proto_send_error_server(PROTO_SEND_ONE, client, PROTO_ERROR_CODE_BAD_VERSION);
- client->status = NET_STATUS_ZOMBIE;
- return;
- }
-
- client->tux = newTux();
- client->tux->control = TUX_CONTROL_NET;
- addList(getCurrentArena()->listTux, client->tux);
-
- if( strlen(name) > STR_NAME_SIZE-1 )
- {
- name[STR_NAME_SIZE-1] = '\0';
- }
-
- strcpy(client->tux->name, name);
- sendInfoCreateClient(client);
-}
-
-void proto_send_status_server(int type, client_t *client)
-{
- char msg[STR_PROTO_SIZE];
-
- sprintf(msg, "version: %s\n"
- "clients: %d\n"
- "maxclients: %d\n"
- "uptime: %d\n",
- TUXANCI_NG_VERSION, getCurrentArena()->listTux->count,
- getServerMaxClients(), getMyTime() );
-
- proto_send(type, client, msg);
-}
-
-void proto_recv_status_server(client_t *client, char *msg)
-{
- proto_send_status_server(PROTO_SEND_ONE, client);
-}
-
-void proto_send_init_server(int type, client_t *client, client_t *client2)
-{
- char msg[STR_PROTO_SIZE];
- int n = WORLD_COUNT_ROUND_UNLIMITED;
-
- assert( client2 != NULL );
-
-#ifndef PUBLIC_SERVER
- getSettingCountRound(&n);
-#endif
-
- sprintf(msg, "init %d %d %d %d %s\n",
- client2->tux->id, client2->tux->x, client2->tux->y,
- n, getArenaNetName( getChoiceArenaId() ));
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_init_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- char arena_name[STR_PROTO_SIZE];
- tux_t *tux;
- int id;
- int x, y, n;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d %d %d %s",
- cmd, &id, &x, &y, &n, arena_name);
-
- setWorldArena( getArenaIdFormNetName(arena_name) );
- setMaxCountRound(n);
-
- tux = newTux();
- tux->id = id;
- tux->x = x;
- tux->y = y;
- tux->control = TUX_CONTROL_KEYBOARD_RIGHT;
-
- getSettingNameRight(tux->name);
-
- addList(getCurrentArena()->listTux, tux);
-}
-
-#endif
-
-void proto_send_event_server(int type, client_t *client, tux_t *tux, int action)
-{
- char msg[STR_PROTO_SIZE];
-
- assert( tux != NULL );
-
- sprintf(msg, "event %d %d\n", tux->id, action);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_event_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int id, action;
- tux_t *tux;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d", cmd, &id, &action);
-
- tux = getTuxID(getCurrentArena()->listTux, id);
-
- if( tux != NULL )
- {
- actionTux(tux, action);
- }
-}
-
-#endif
-
-#ifndef PUBLIC_SERVER
-
-void proto_send_event_client(int action)
-{
- char msg[STR_PROTO_SIZE];
-
- sprintf(msg, "event %d\n", action);
-
- sendServer(msg);
-}
-
-#endif
-
-void proto_recv_event_server(client_t *client, char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int action;
-
- assert( client != NULL );
- assert( msg != NULL );
-
- sscanf(msg, "%s %d", cmd, &action);
-
- proto_send_event_server(PROTO_SEND_BUT, client, client->tux, action);
-
- actionTux(client->tux, action);
-
-}
-
-void proto_send_newtux_server(int type, client_t *client, tux_t *tux)
-{
- char msg[STR_PROTO_SIZE];
- int x, y;
-
- assert( tux != NULL );
-
- if( tux->bonus == BONUS_HIDDEN )
- {
- x = TUX_LOCATE_UNKNOWN;
- y = TUX_LOCATE_UNKNOWN;
- }
- else
- {
- x = tux->x;
- y = tux->y;
- }
-
- sprintf(msg, "newtux %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d\n",
- tux->id ,x, y, tux->status, tux->position ,tux->frame, tux->score, tux->name,
- tux->gun, tux->bonus, tux->shot[GUN_SIMPLE], tux->shot[GUN_DUAL_SIMPLE],
- tux->shot[GUN_SCATTER], tux->shot[GUN_TOMMY], tux->shot[GUN_LASSER],
- tux->shot[GUN_MINE], tux->shot[GUN_BOMBBALL],
- tux->bonus_time, tux->pickup_time);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_newtux_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- char name[STR_NAME_SIZE];
- int id, x, y, status, position, frame, score;
- int myGun, myBonus;
- int gun1, gun2, gun3, gun4, gun5, gun6, gun7;
- int time1, time2;
- tux_t *tux;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d",
- cmd, &id, &x, &y, &status, &position, &frame, &score, name,
- &myGun, &myBonus, &gun1, &gun2, &gun3, &gun4, &gun5, &gun6, &gun7, &time1, &time2);
-
- tux = getTuxID(getCurrentArena()->listTux, id);
-
- if( tux == NULL )
- {
- char term_msg[STR_SIZE];
- sprintf(term_msg, "connect new client( id = %d)\n", id);
- appendTextInTerm(term_msg);
-
- tux = newTux();
- tux->control = TUX_CONTROL_NET;
- addList(getCurrentArena()->listTux, tux);
- }
-
- tux->id = id;
-
- tux->x = x;
- tux->y = y;
- tux->status = status;
- tux->position = position;
- tux->frame = frame;
- tux->score = score;
- strcpy(tux->name, name);
- tux->gun = myGun;
- tux->bonus = myBonus;
- tux->shot[GUN_SIMPLE] = gun1;
- tux->shot[GUN_DUAL_SIMPLE] = gun2;
- tux->shot[GUN_SCATTER] = gun3;
- tux->shot[GUN_TOMMY] = gun4;
- tux->shot[GUN_LASSER] = gun5;
- tux->shot[GUN_MINE] = gun6;
- tux->shot[GUN_BOMBBALL] = gun7;
- tux->bonus_time = time1;
- tux->pickup_time = time2;
-}
-
-#endif
-
-void proto_send_kill_server(int type, client_t *client, tux_t *tux)
-{
- char msg[STR_PROTO_SIZE];
-
- assert( tux != NULL );
-
- sprintf(msg, "kill %d\n", tux->id);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_kill_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int id;
- tux_t *tux;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d", cmd, &id);
-
- tux = getTuxID(getCurrentArena()->listTux, id);
-
- if( tux != NULL )
- {
- eventTuxIsDead(tux);
- }
-}
-
-#endif
-
-void proto_send_score_server(int type, client_t *client, tux_t *tux)
-{
- char msg[STR_PROTO_SIZE];
-
- assert( tux != NULL );
-
- sprintf(msg, "score %d %d\n", tux->id, tux->score);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_score_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int id, score;
- tux_t *tux;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d", cmd, &id, &score);
-
- tux = getTuxID(getCurrentArena()->listTux, id);
-
- if( tux != NULL )
- {
- char term_msg[STR_SIZE];
- sprintf(term_msg, "tux with id %d set score to %d\n", tux->id, score);
- appendTextInTerm(term_msg);
-
- tux->score = score;
- }
-
- countRoundInc();
-}
-
-#endif
-
-void proto_send_deltux_server(int type, client_t *client, client_t *client2)
-{
- char msg[STR_PROTO_SIZE];
-
- assert( client2 != NULL );
-
- sprintf(msg, "deltux %d\n", client2->tux->id);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_deltux_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int id;
- tux_t *tux;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d", cmd, &id);
-
- tux = getTuxID(getCurrentArena()->listTux, id);
-
- if( tux != NULL )
- {
- char term_msg[STR_SIZE];
- int index;
-
- sprintf(term_msg, "tux with id %d is disconnect\n", tux->id);
- appendTextInTerm(term_msg);
-
- index = searchListItem(getCurrentArena()->listTux, tux);
- delListItem(getCurrentArena()->listTux, index, destroyTux);
- }
-}
-
-#endif
-
-void proto_send_additem_server(int type, client_t *client, item_t *p)
-{
- char msg[STR_PROTO_SIZE];
- int id = -1;
-
- assert( p != NULL );
-
- if( p->author != NULL )
- {
- id = p->author->id;
- }
-
- sprintf(msg, "additem %d %d %d %d %d %d %d\n",
- p->id, p->type, p->x, p->y, p->count, p->frame, id);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_additem_client(char *msg)
-{
- char term_msg[STR_SIZE];
- char cmd[STR_PROTO_SIZE];
- int id, type, x, y, count, frame, author_id;
- item_t *item;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d %d %d %d %d %d", cmd, &id, &type, &x, &y, &count, &frame, &author_id);
-
- if( getItemID(getCurrentArena()->listItem, id) != NULL )
- {
- return;
- }
-
- item = newItem(x, y, type, getTuxID(getCurrentArena()->listTux, author_id));
-/*
- if( isConflictWithListItem(getCurrentArena()->listItem, item->x, item->y, item->w, item->h) )
- {
- destroyItem(item);
- return;
- }
-*/
- item->id = id;
- item->count = count;
- item->frame = frame;
-
- addList(getCurrentArena()->listItem, item);
-
- sprintf(term_msg, "in arena is new item\n");
- appendTextInTerm(term_msg);
-
-}
-
-#endif
-
-void proto_send_item_server(int type, client_t *client, tux_t *tux, item_t *item)
-{
- char msg[STR_PROTO_SIZE];
- int tux_id = -1;
-
- assert( item != NULL );
-
- if( tux != NULL )
- {
- tux_id = tux->id;
- }
-
- sprintf(msg, "item %d %d\n",
- tux_id, item->id);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_item_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int tux_id, item_id;
- arena_t *arena;
-
- item_t *item;
- tux_t *tux;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d", cmd, &tux_id, &item_id);
-
- arena = getCurrentArena();
-
- item = getItemID(arena->listItem, item_id);
- tux = getTuxID(arena->listTux, tux_id);
-
- if( item == NULL)
- {
- return;
- }
-
- if( tux != NULL )
- {
- eventGiveTuxItem(tux, arena->listItem, item);
- }
- else
- {
- mineExplosion(arena->listItem, item);
- }
-}
-
-#endif
-
-void proto_send_shot_server(int type, client_t *client, shot_t *p)
-{
- char msg[STR_PROTO_SIZE];
- int id = -1;
-
- assert( p != NULL );
-
- if( p->author != NULL )
- {
- id = p->author->id;
- }
-
- sprintf(msg, "shot %d %d %d %d %d %d %d %d\n",
- p->x, p->y, p->px, p->py, p->position, p->gun, id, p->isCanKillAuthor);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_shot_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int x, y, px, py, position, gun, id, isCanKillAuthor;
- shot_t *shot;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d %d %d %d %d %d %d",
- cmd, &x, &y, &px, &py, &position, &gun, &id, &isCanKillAuthor);
-
- shot = newShot(x, y, px, py, gun, getTuxID(getCurrentArena()->listTux, id));
-
- shot->isCanKillAuthor = isCanKillAuthor;
- shot->position = position;
-
- if( shot->gun == GUN_LASSER )
- {
- transformOnlyLasser(shot);
- }
-
- addList(getCurrentArena()->listShot, shot);
-}
-
-#endif
-
-#ifndef PUBLIC_SERVER
-
-void proto_send_ping_client()
-{
- char msg[STR_PROTO_SIZE];
- sprintf(msg, "ping %d\n", getMyTime());
- sendServer(msg);
-}
-
-#endif
-
-void proto_recv_ping_server(client_t *client, char *msg)
-{
- proto_send_ping_server(PROTO_SEND_ONE, client, msg);
-}
-
-void proto_send_ping_server(int type, client_t *client, char *msg)
-{
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_ping_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- my_time_t currentTime;
- my_time_t time;
-
- sscanf(msg, "%s %d", cmd, &time);
-
- currentTime = getMyTime();
- printf("lag = %d\n", (currentTime-time));
- setLagServer((currentTime-time));
-}
-
-#endif
-
-void proto_send_end_server(int type, client_t *client)
-{
- char msg[STR_PROTO_SIZE];
- strcpy(msg, "end\n");
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_end_client(char *msg)
-{
- assert( msg != NULL );
-
- setWorldEnd();
-}
-
-#endif
-
-#ifndef PUBLIC_SERVER
-
-void proto_send_end_client()
-{
- char msg[STR_PROTO_SIZE];
- strcpy(msg, "end\n");
- sendServer(msg);
-}
-
-#endif
-
-void proto_recv_end_server(client_t *client, char *msg)
-{
- assert( msg != NULL );
- assert( client != NULL );
-
- client->status = NET_STATUS_ZOMBIE;
-}
-