From 29173b3199ea526b6f9de13ee9255db3900f3f42 Mon Sep 17 00:00:00 2001 From: oroborus Date: Wed, 30 Apr 2008 19:11:49 +0000 Subject: - program si kontroluje ci existuju subory ktore pouziva git-svn-id: http://opensvn.csie.org/tuxanci_ng@48 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/arenaFile.c | 2 ++ src/client.c | 2 +- src/font.c | 2 ++ src/image.c | 3 +++ src/interface.c | 16 ++++++++++++++++ src/item.c | 2 +- src/language.c | 2 ++ src/main.c | 12 ++++++++++++ src/music.c | 3 +++ src/screen_credits.c | 1 + src/server.c | 2 +- src/sound.c | 4 ++++ 12 files changed, 48 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/arenaFile.c b/src/arenaFile.c index fdf80fb..b829e9e 100644 --- a/src/arenaFile.c +++ b/src/arenaFile.c @@ -311,6 +311,8 @@ void initArenaFile() sprintf(path, PATH_ARENA "%s", line); printf("load map %s\n", line); + + accessExistFile(path); addList(listArenaFile, loadTextFile(path)); } } diff --git a/src/client.c b/src/client.c index a047a2a..9fc5e07 100644 --- a/src/client.c +++ b/src/client.c @@ -143,8 +143,8 @@ void eventServerBuffer() while ( getBufferLine(clientBuffer, line, STR_PROTO_SIZE) >= 0 ) { #ifdef DEBUG_CLIENT_RECV - printf("recv server msg->%s", line); #endif + printf("recv server msg->%s", line); if( strncmp(line, "error", 5) == 0 )proto_recv_error_client(line); if( strncmp(line, "init", 4) == 0 )proto_recv_init_client(line); diff --git a/src/font.c b/src/font.c index a9fb817..0f1c200 100755 --- a/src/font.c +++ b/src/font.c @@ -37,6 +37,8 @@ void initFont(char *file,int size) return; } + accessExistFile(str); + g_font = TTF_OpenFont(str, size); TTF_SetFontStyle(g_font, TTF_STYLE_NORMAL); diff --git a/src/image.c b/src/image.c index 3726167..a7c2261 100755 --- a/src/image.c +++ b/src/image.c @@ -38,8 +38,11 @@ static SDL_Surface *loadImage(const char *filename, int alpha) char str[STR_PATH_SIZE]; + sprintf(str, PATH_IMAGE "%s", filename); + accessExistFile(str); + if( ( tmp = IMG_Load(str) ) == NULL ) { fprintf(stderr, "%s\n", SDL_GetError()); diff --git a/src/interface.c b/src/interface.c index 9e0d6bf..1da3989 100755 --- a/src/interface.c +++ b/src/interface.c @@ -138,6 +138,22 @@ int isPessAnyKey() return 0; } +void printPessAnyKey() +{ + Uint8 *mapa; + int i; + + mapa = SDL_GetKeyState(NULL); + + for( i = SDLK_BACKSPACE ; i < SDLK_KP9 ; i++ ) + if( mapa[i] == SDL_PRESSED ) + { + printf("press key with code : %d\n", i); + } + +} + + /* static void action_esc() { diff --git a/src/item.c b/src/item.c index c336cd4..70b43fb 100644 --- a/src/item.c +++ b/src/item.c @@ -416,7 +416,7 @@ void eventConflictShotWithItem(list_t *listItem, list_t *listShot) if( isDelShot ) { - printf("del shot\n"); + //printf("del shot\n"); delListItem(listShot, i, destroyShot); i--; } diff --git a/src/language.c b/src/language.c index 5291f44..ee9b18c 100644 --- a/src/language.c +++ b/src/language.c @@ -70,6 +70,8 @@ int initLanguage() printf("select lang %s\n", lang); sprintf(path, PATH_LANG "%s.lang", lang); + + accessExistFile(path); languageFile = loadTextFile(path); if( languageFile == NULL ) diff --git a/src/main.c b/src/main.c index 0978f89..c1c3371 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include "main.h" #include "tux.h" @@ -170,6 +173,15 @@ char *getString(int n) return strdup(str); } +void accessExistFile(const char *s) +{ + if( access(s, F_OK) != 0 ) + { + fprintf(stderr, "File %s not fount !\nProgram shutdown !\n", s); + exit(-1); + } +} + int main(int argc, char *argv[]) { srand( (unsigned) time(NULL) ); diff --git a/src/music.c b/src/music.c index c2f3f16..5ef4ae6 100644 --- a/src/music.c +++ b/src/music.c @@ -54,9 +54,12 @@ static Mix_Music* loadMixMusic(char *file) Mix_Music *new; char str[STR_PATH_SIZE]; + printf("load music %s..\n", file); sprintf(str, PATH_MUSIC "%s", file); + accessExistFile(str); + new = Mix_LoadMUS(str); if( new == NULL ) diff --git a/src/screen_credits.c b/src/screen_credits.c index b42cfe1..ce352f9 100644 --- a/src/screen_credits.c +++ b/src/screen_credits.c @@ -97,6 +97,7 @@ void initScreenCredits() button_back = newWidgetButton(getMyText("BACK"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, WINDOW_SIZE_Y-80, eventWidget); listWidgetLabel = newList(); + accessExistFile(PATH_DATA SCREEN_CREDITS_FILE); textFile = loadTextFile(PATH_DATA SCREEN_CREDITS_FILE); for( i = 0 ; i < textFile->text->count ; i++ ) diff --git a/src/server.c b/src/server.c index afebb10..37f38eb 100644 --- a/src/server.c +++ b/src/server.c @@ -152,7 +152,7 @@ void static initServer() addTaskToTimer(listServerTimer, TIMER_PERIODIC, delZombieCLient, NULL, SERVER_TIMEOUT); addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncClient, NULL, SERVER_TIME_SYNC); - addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncSelfClient, NULL, 5000); + //addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncSelfClient, NULL, 5000); addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventSendPingClients, NULL, SERVER_TIME_PING); } diff --git a/src/sound.c b/src/sound.c index 4d574b8..3dc5552 100644 --- a/src/sound.c +++ b/src/sound.c @@ -51,8 +51,12 @@ static Mix_Chunk* loadMixSound(char *file) Mix_Chunk *new; char str[STR_PATH_SIZE]; + printf("load sound %s..\n", file); sprintf(str, PATH_SOUND "%s", file); + + accessExistFile(str); + new = Mix_LoadWAV(str); if( new == NULL ) -- cgit v1.2.3