summaryrefslogtreecommitdiff
path: root/src/screen
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-05 15:56:13 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-05 15:56:13 +0000
commit6ed79c5de77b3f6be5c297cb5432d123ff1ff177 (patch)
treea21336754348eb80263aa72768a474c500c8a607 /src/screen
parent17b80069913989598a27fc31b952407f895f5b51 (diff)
- miny sa nezobrazuju na radare
- tux moze chodit strielat a zmenit zbran sucastne - master server sa pouziga ten na "ms.tuxanci.org" - AI sa nastavuje v GUI ako v TFG git-svn-id: http://opensvn.csie.org/tuxanci_ng@93 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/screen')
-rw-r--r--src/screen/screen_browser.c15
-rw-r--r--src/screen/screen_setting.c48
-rw-r--r--src/screen/screen_setting.h2
-rw-r--r--src/screen/screen_world.c45
4 files changed, 53 insertions, 57 deletions
diff --git a/src/screen/screen_browser.c b/src/screen/screen_browser.c
index 44b0411..5d99cf7 100644
--- a/src/screen/screen_browser.c
+++ b/src/screen/screen_browser.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include "net_unix/udp.h"
+#include "net_unix/dns.h"
extern int errno;
#endif
@@ -377,11 +378,23 @@ static int LoadServers ()
/* TODO: dodelat TCP makro */
#ifdef SUPPORT_NET_UNIX_UDP
struct sockaddr_in server;
+ char *master_server_ip;
+
+ master_server_ip = getIPFormDNS(NET_MASTER_SERVER_DOMAIN);
+
+ //printf("master_server_ip = %s\n", master_server_ip);
+
+ if( master_server_ip == NULL ) // master server is down
+ {
+ return -1;
+ }
server.sin_family = AF_INET;
server.sin_port = htons (NET_MASTER_PORT);
- server.sin_addr.s_addr = inet_addr (NET_MASTER_SERVER);
+ server.sin_addr.s_addr = inet_addr (master_server_ip);
+ free(master_server_ip);
+
if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
close (s);
return 0;
diff --git a/src/screen/screen_setting.c b/src/screen/screen_setting.c
index fd1388d..5a7fb29 100644
--- a/src/screen/screen_setting.c
+++ b/src/screen/screen_setting.c
@@ -69,7 +69,7 @@ static widget_textfield_t *textfield_count_cound;
static widget_textfield_t *textfield_name_player1;
static widget_textfield_t *textfield_name_player2;
-static widget_select_t *select_ai;
+static widget_check_t *check_ai;
static textFile_t *configFile;
@@ -129,7 +129,7 @@ void drawScreenSetting()
drawWidgetCheck(check[i]);
}
- drawWidgetSelect(select_ai);
+ drawWidgetCheck(check_ai);
drawWidgetButton(button_back);
}
@@ -166,7 +166,7 @@ void eventScreenSetting()
eventWidgetCheck(check[i]);
}
- eventWidgetSelect(select_ai);
+ eventWidgetCheck(check_ai);
eventWidgetButton(button_back);
}
@@ -257,6 +257,9 @@ static void initSettingFile()
loadValueFromConfigFile(configFile, "BONUS_HIDDEN", val, STR_SIZE, "YES");
check[BONUS_HIDDEN]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "AI", val, STR_SIZE, "NO");
+ check_ai->status = isYesOrNO(val);
+
#ifndef NO_SOUND
loadValueFromConfigFile(configFile, "MUSIC", val, STR_SIZE, "YES");
check_music->status = isYesOrNO(val);
@@ -295,6 +298,8 @@ static void saveAndDestroyConfigFile()
setValueInConfigFile(configFile, "BONUS_4X", getYesOrNo(check[BONUS_4X]->status) );
setValueInConfigFile(configFile, "BONUS_HIDDEN", getYesOrNo(check[BONUS_HIDDEN]->status) );
+ setValueInConfigFile(configFile, "AI", getYesOrNo(check_ai->status) );
+
#ifndef NO_SOUND
setValueInConfigFile(configFile, "MUSIC", getYesOrNo(check_music->status) );
setValueInConfigFile(configFile, "SOUND", getYesOrNo(check_sound->status) );
@@ -304,29 +309,6 @@ static void saveAndDestroyConfigFile()
destroyTextFile(configFile);
}
-static void findModulesAI()
-{
- director_t *listModules;
- int i;
-
- listModules = loadDirector(PATH_MODULES);
-
- for( i = 0 ; i < listModules->list->count ; i++)
- {
- char *line;
-
- line = (char *)listModules->list->list[i];
-
- if( strstr(line,"AI") != NULL &&
- strstr(line,".so") != NULL )
- {
- addToWidgetSelect(select_ai, line);
- }
- }
-
- destroyDirector(listModules);
-}
-
void initScreenSetting()
{
SDL_Surface *image;
@@ -357,6 +339,8 @@ void initScreenSetting()
WINDOW_SIZE_Y-80, isSoundActive() , eventWidget);
#endif
+ check_ai = newWidgetCheck(460, 405, FALSE, eventWidget);
+
for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
{
int x = 0;
@@ -416,10 +400,6 @@ void initScreenSetting()
initSettingFile();
- select_ai = newWidgetSelect(label_ai->x, label_ai->y+40, eventWidget);
- addToWidgetSelect(select_ai, "none");
- findModulesAI();
-
#ifndef NO_SOUND
eventWidget(check_music);
eventWidget(check_sound);
@@ -441,9 +421,9 @@ void getSettingCountRound(int *n)
*n = atoi( textfield_count_cound->text );
}
-char* getSettingAI()
+bool_t isSettingAI()
{
- return (char *) select_ai->list->list[ select_ai->select ];
+ return check_ai->status;
}
bool_t isSettingAnyItem()
@@ -515,6 +495,8 @@ void quitScreenSetting()
destroyWidgetCheck(check_sound);
#endif
+ destroyWidgetCheck(check_ai);
+
for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
{
destroyWidgetCheck(check[i]);
@@ -525,8 +507,6 @@ void quitScreenSetting()
destroyWidgetCheck(check[i]);
}
- destroyWidgetSelect(select_ai);
-
destroyWidgetButton(button_back);
}
diff --git a/src/screen/screen_setting.h b/src/screen/screen_setting.h
index 5b0bae3..b9631f8 100644
--- a/src/screen/screen_setting.h
+++ b/src/screen/screen_setting.h
@@ -11,7 +11,7 @@ extern void eventScreenSetting();
extern void getSettingNameRight(char *s);
extern void getSettingNameLeft(char *s);
extern void getSettingCountRound(int *n);
-extern char* getSettingAI();
+extern bool_t isSettingAI();
extern bool_t isSettingAnyItem();
extern bool_t isSettingItem(int item);
extern void quitScreenSetting();
diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c
index 380fd43..91820ff 100644
--- a/src/screen/screen_world.c
+++ b/src/screen/screen_world.c
@@ -148,10 +148,12 @@ void prepareArena()
getSettingNameLeft(tux->name);
addObjectToSpace(arena->spaceTux, tux);
- if( strcmp(getSettingAI(), "none") != 0 )
+ if( isSettingAI() )
{
- loadModule( getSettingAI() );
- tux->control = TUX_CONTROL_AI;
+ if( loadModule("modAI.so") == 0 )
+ {
+ tux->control = TUX_CONTROL_AI;
+ }
}
break;
@@ -237,6 +239,16 @@ static void control_keyboard_right(tux_t *tux)
if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED )
+ {
+ if( tux->isCanSwitchGun == TRUE )
+ {
+ netAction(tux, TUX_SWITCH_GUN);
+ actionTux(tux, TUX_SWITCH_GUN);
+ return;
+ }
+ }
+
if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
{
netAction(tux, TUX_SHOT);
@@ -292,16 +304,6 @@ static void control_keyboard_right(tux_t *tux)
tuDown:;
}
-
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED )
- {
- if( tux->isCanSwitchGun == TRUE )
- {
- netAction(tux, TUX_SWITCH_GUN);
- actionTux(tux, TUX_SWITCH_GUN);
- return;
- }
- }
}
static void control_keyboard_left(tux_t *tux)
@@ -321,6 +323,15 @@ static void control_keyboard_left(tux_t *tux)
if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
+ if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED )
+ {
+ if( tux->isCanSwitchGun == TRUE )
+ {
+ actionTux(tux, TUX_SWITCH_GUN);
+ return;
+ }
+ }
+
if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
{
actionTux(tux, TUX_SHOT);
@@ -372,14 +383,6 @@ static void control_keyboard_left(tux_t *tux)
tuDown:;
}
- if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED )
- {
- if( tux->isCanSwitchGun == TRUE )
- {
- actionTux(tux, TUX_SWITCH_GUN);
- return;
- }
- }
/*
if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )actionTux(tux, TUX_UP);
if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )actionTux(tux, TUX_RIGHT);