summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-07 20:49:54 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-07 20:49:54 +0000
commit776577985a056407645a448f8332d6ce69d645a3 (patch)
tree7f279fdce8100ce64409c2117c53b03443e5e5e1 /src
parent6ca82a3f9841941caef20380fe014a8d4ac5349b (diff)
- opravy v kodu, ktory obsluhuje konfig
- oprava v screen_setting - oprava v layer git-svn-id: http://opensvn.csie.org/tuxanci_ng@123 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src')
-rwxr-xr-xsrc/base/modules.c2
-rw-r--r--src/client/configFile.c13
-rwxr-xr-xsrc/client/layer.c44
-rwxr-xr-xsrc/modules/modAI.c2
-rwxr-xr-xsrc/modules/modPipe.c2
-rwxr-xr-xsrc/modules/modTeleport.c2
-rwxr-xr-xsrc/modules/modWall.c5
-rw-r--r--src/screen/screen_credits.c1
-rw-r--r--src/screen/screen_setting.c50
-rw-r--r--src/screen/screen_setting.h4
-rw-r--r--src/screen/screen_world.c8
11 files changed, 52 insertions, 81 deletions
diff --git a/src/base/modules.c b/src/base/modules.c
index 108990f..8b84987 100755
--- a/src/base/modules.c
+++ b/src/base/modules.c
@@ -100,7 +100,7 @@ static module_t* newModule(char *name)
ret->fce_event = getFce(ret, "event");
ret->fce_destroy = getFce(ret, "destroy");
ret->fce_isConflict = getFce(ret, "isConflict");
- ret->fce_cmd = getFce(ret, "cmd");
+ ret->fce_cmd = getFce(ret, "cmdArena");
printf("load module.. (%s)\n", name);
diff --git a/src/client/configFile.c b/src/client/configFile.c
index 1c19e3f..f900910 100644
--- a/src/client/configFile.c
+++ b/src/client/configFile.c
@@ -26,8 +26,7 @@ int getValue(char *line, char *env, char *val, int len)
char clone_env[STR_SIZE];
int val_len;
- strcpy(clone_env, " ");
- strcat(clone_env, env);
+ strcpy(clone_env, env);
offset_env = strstr(line, clone_env);
if( offset_env == NULL )return -1;
@@ -83,8 +82,10 @@ int getValueInConfigFile(textFile_t *textFile, char *env, char *val, int len)
for( i = 0 ; i < textFile->text->count ; i++ )
{
line = (char *) (textFile->text->list[i]);
-
- if( strstr(line, env) != NULL )
+
+ //printf("env = %s line = %s\n", env, line);
+
+ if( strncmp(line, env, strlen(env)) == 0 )
{
return getValue(line, env, val, len);
}
@@ -103,7 +104,7 @@ int setValueInConfigFile(textFile_t *textFile, char *env, char *val)
{
line = (char *) (textFile->text->list[i]);
- if( strstr(line, env) != NULL )
+ if( strncmp(line, env, strlen(env)) == 0 )
{
ret = setValue(line, env, val);
@@ -128,7 +129,7 @@ void loadValueFromConfigFile(textFile_t *textFile, char *env, char *val, int len
{
char line[STR_SIZE];
- sprintf(line, " %s=\"%s\"", env, butVal);
+ sprintf(line, "%s=\"%s\"", env, butVal);
addList(textFile->text, strdup(line) );
printf("Add line \"%s\" in config file.\n", line);
diff --git a/src/client/layer.c b/src/client/layer.c
index d4fcb7b..9354aae 100755
--- a/src/client/layer.c
+++ b/src/client/layer.c
@@ -26,7 +26,9 @@ bool_t isLayerInicialized()
*/
void initLayer()
{
+ printf("*******************\nnew layer\n**********************\n");
listLayer = newList();
+ isLayerInit = TRUE;
}
/*
@@ -42,7 +44,7 @@ void addLayer(SDL_Surface *img,
{
layer_t *new;
layer_t *this;
- int i;
+ int i, j;
assert( img != NULL );
@@ -56,32 +58,26 @@ void addLayer(SDL_Surface *img,
new->layer = player;
new->image = img;
- if( listLayer->count == 0 )
- {
- addList(listLayer, new);
- return;
- }
-
- i = 0;
- this = (layer_t *)listLayer->list[0];
-
- //vyhladaj svoju vrstvu
- while( i < listLayer->count && this->layer < new->layer )
- {
- this = (layer_t *)listLayer->list[++i];
- }
-
- //porovnaj s vyskami na tvojej vrstve,
- //ak neexistuje, rovno to tam hod
- this = (layer_t *)listLayer->list[i];
-
- while( i < listLayer->count && this->y+this->h < new->y+new->h && new->layer == this->layer )
+ for( i = 0 ; i < listLayer->count ; i++ )
{
- this = (layer_t *)listLayer->list[++i];
+ this = (layer_t *)listLayer->list[i];
+
+ if( this->layer == new->layer )
+ {
+ for( j = i ; j < listLayer->count ; j++ )
+ {
+ this = (layer_t *)listLayer->list[j];
+
+ if( this->y+this->h > new->y+new->h )
+ {
+ insList(listLayer, j, new);
+ return;
+ }
+ }
+ }
}
- insList(listLayer, i, new);
- isLayerInit = TRUE;
+ addList(listLayer, new);
}
/*
diff --git a/src/modules/modAI.c b/src/modules/modAI.c
index d244aa3..61cb23f 100755
--- a/src/modules/modAI.c
+++ b/src/modules/modAI.c
@@ -242,7 +242,7 @@ int isConflict(int x, int y, int w, int h)
return 0;
}
-void cmd(char *line)
+void cmdArena(char *line)
{
if( strncmp(line, "ai", 2) == 0 )cmd_ai(line);
}
diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c
index 2ca2f17..b535404 100755
--- a/src/modules/modPipe.c
+++ b/src/modules/modPipe.c
@@ -441,7 +441,7 @@ int isConflict(int x, int y, int w, int h)
return isConflictWithObjectFromSpace(spacePipe, x, y, w, h);
}
-void cmd(char *line)
+void cmdArena(char *line)
{
if( strncmp(line, "pipe", 4) == 0 )cmd_teleport(line);
}
diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c
index 0bc4c61..72b3690 100755
--- a/src/modules/modTeleport.c
+++ b/src/modules/modTeleport.c
@@ -494,7 +494,7 @@ int isConflict(int x, int y, int w, int h)
return 0;
}
-void cmd(char *line)
+void cmdArena(char *line)
{
if( strncmp(line, "teleport", 8) == 0 )cmd_teleport(line);
}
diff --git a/src/modules/modWall.c b/src/modules/modWall.c
index 7d36957..4544ea9 100755
--- a/src/modules/modWall.c
+++ b/src/modules/modWall.c
@@ -220,7 +220,7 @@ static void cmd_wall(char *line)
rel = 0;
- if( export_fce->fce_getValue(line, "rel", str_rel, STR_NUM_SIZE) != 0 );
+ if( export_fce->fce_getValue(line, "rel", str_rel, STR_NUM_SIZE) != 0 )strcpy(str_rel, "0");
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;
@@ -230,7 +230,6 @@ static void cmd_wall(char *line)
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;
-
rel = atoi(str_rel);
x = atoi(str_x);
y = atoi(str_y);
@@ -330,7 +329,7 @@ int isConflict(int x, int y, int w, int h)
return isConflictWithObjectFromSpace(spaceWall, x, y, w, h);
}
-void cmd(char *line)
+void cmdArena(char *line)
{
if( strncmp(line, "wall", 4) == 0 )cmd_wall(line);
}
diff --git a/src/screen/screen_credits.c b/src/screen/screen_credits.c
index 39859cd..6de034a 100644
--- a/src/screen/screen_credits.c
+++ b/src/screen/screen_credits.c
@@ -27,6 +27,7 @@ static list_t *listWidgetLabel;
static textFile_t *textFile;
static int offset;
static int creditExists;
+
void startScreenCredits()
{
#ifndef NO_SOUND
diff --git a/src/screen/screen_setting.c b/src/screen/screen_setting.c
index e4936f2..d853265 100644
--- a/src/screen/screen_setting.c
+++ b/src/screen/screen_setting.c
@@ -207,22 +207,6 @@ static void eventWidget(void *p)
setSoundActive( check_sound->status );
}
#endif
- if( check == check_ai )
- {
- if ( check_ai->status )
- {
- // ai je zapnuto nechceme hrace 2
- destroyWidgetTextfield(textfield_name_player2);
- destroyWidgetLabel(label_name_player2);
- }
- else {
- // ai je vypnuto chceme hrace 2
- label_name_player2 = newWidgetLabel(getMyText("NAME_PLAYER2"), 100, WINDOW_SIZE_Y-120, WIDGET_LABEL_LEFT);
- drawWidgetLabel(label_name_player2);
- textfield_name_player2 = newWidgetTextfield(getParamElse("--name2", "TUX Warrior #02"), 110+label_name_player2->w, WINDOW_SIZE_Y-120);
- drawWidgetTextfield(textfield_name_player2);
- }
- }
}
static void initSettingFile()
@@ -309,17 +293,7 @@ static void saveAndDestroyConfigFile()
setValueInConfigFile(configFile, "COUNT_ROUND", textfield_count_cound->text );
setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", textfield_name_player1->text );
-
- if( check_ai->status )
- {
- loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE, "TUX Warrior #02");
- strcpy(name2, val);
- setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", name2 );
- }
- else
- {
- setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", textfield_name_player2->text );
- }
+ setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", textfield_name_player2->text );
setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE", getYesOrNo(check[GUN_DUAL_SIMPLE]->status) );
setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(check[GUN_SCATTER]->status) );
@@ -327,6 +301,7 @@ static void saveAndDestroyConfigFile()
setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(check[GUN_LASSER]->status) );
setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(check[GUN_MINE]->status) );
setValueInConfigFile(configFile, "GUN_BOMBBALL", getYesOrNo(check[GUN_BOMBBALL]->status) );
+
setValueInConfigFile(configFile, "BONUS_SPEED", getYesOrNo(check[BONUS_SPEED]->status) );
setValueInConfigFile(configFile, "BONUS_SHOT", getYesOrNo(check[BONUS_SHOT]->status) );
setValueInConfigFile(configFile, "BONUS_TELEPORT", getYesOrNo(check[BONUS_TELEPORT]->status) );
@@ -376,9 +351,8 @@ void initScreenSetting()
textfield_count_cound = newWidgetTextfield(getParamElse("--count", "15"), 110+label_count_round->w, WINDOW_SIZE_Y-200);
- textfield_name_player1 = newWidgetTextfield(getParamElse("--name1", "TUX Warrior #01"), 110+label_name_player1->w, WINDOW_SIZE_Y-160);
- if ( check_ai->status == 0 )
- textfield_name_player2 = newWidgetTextfield(getParamElse("--name2", "TUX Warrior #02"), 110+label_name_player2->w, WINDOW_SIZE_Y-120);
+ textfield_name_player1 = newWidgetTextfield(getParamElse("--name1", NAME_PLAYER_RIGHT), 110+label_name_player1->w, WINDOW_SIZE_Y-160);
+ textfield_name_player2 = newWidgetTextfield(getParamElse("--name2", NAME_PLAYER_LEFT), 110+label_name_player2->w, WINDOW_SIZE_Y-120);
for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ )
{
@@ -452,7 +426,14 @@ void getSettingNameRight(char *s)
void getSettingNameLeft(char *s)
{
- strcpy(s, textfield_name_player2->text);
+ if( check_ai->status )
+ {
+ strcpy(s, NAME_AI);
+ }
+ else
+ {
+ strcpy(s, textfield_name_player2->text);
+ }
}
void getSettingCountRound(int *n)
@@ -509,11 +490,8 @@ void quitScreenSetting()
destroyWidgetLabel(label_music);
destroyWidgetLabel(label_sound);
#endif
- if ( check_ai->status == 0 )
- {
- destroyWidgetLabel(label_name_player2);
- destroyWidgetTextfield(textfield_name_player2);
- }
+ destroyWidgetLabel(label_name_player2);
+ destroyWidgetTextfield(textfield_name_player2);
destroyWidgetTextfield(textfield_name_player1);
destroyWidgetTextfield(textfield_count_cound);
diff --git a/src/screen/screen_setting.h b/src/screen/screen_setting.h
index 744e768..d80a7a5 100644
--- a/src/screen/screen_setting.h
+++ b/src/screen/screen_setting.h
@@ -5,6 +5,10 @@
#include "main.h"
+#define NAME_AI "tuxAI"
+#define NAME_PLAYER_RIGHT "TUX Warrior #01"
+#define NAME_PLAYER_LEFT "TUX Warrior #02"
+
extern void initScreenSetting();
extern void drawScreenSetting();
extern void eventScreenSetting();
diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c
index 16fffe8..f5556c9 100644
--- a/src/screen/screen_world.c
+++ b/src/screen/screen_world.c
@@ -43,7 +43,6 @@
static arena_t *arena;
static int count;
static int max_count;
-static my_time_t lastServerLag;
static bool_t isScreenWorldInit = FALSE;
static bool_t isEndWorld;
@@ -82,11 +81,6 @@ void setMaxCountRound(int n)
max_count = n;
}
-void setLagServer(my_time_t lag)
-{
- lastServerLag = lag;
-}
-
void setWorldEnd()
{
isEndWorld = TRUE;
@@ -373,7 +367,6 @@ static void eventEsc()
if( mapa[(SDLKey)SDLK_ESCAPE] == SDL_PRESSED && isChatActive() == FALSE )
{
- isEndWorld = TRUE;
setWorldEnd();
return;
}
@@ -493,7 +486,6 @@ void startWorld()
isEndWorld = FALSE;
count = 0;
- lastServerLag = LAG_SERVER_UNKNOWN;
initListID();
initRadar();