diff options
| author | scarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-15 19:57:10 +0000 |
|---|---|---|
| committer | scarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-15 19:57:10 +0000 |
| commit | 7bbd60007620cf3cc3ee7a913f7010588808ebb2 (patch) | |
| tree | 34e72f66dfd1076e23c43074786f935aca70cba1 /src/base/arenaFile.c | |
| parent | 50ba3d5e1e9f9eeda049a348efa4645af07610bc (diff) | |
"- initial commit for GETTEXT support and K&R compilance"
git-svn-id: http://opensvn.csie.org/tuxanci_ng@196 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/base/arenaFile.c')
| -rw-r--r-- | src/base/arenaFile.c | 125 |
1 files changed, 54 insertions, 71 deletions
diff --git a/src/base/arenaFile.c b/src/base/arenaFile.c index 3375843..b89e1c3 100644 --- a/src/base/arenaFile.c +++ b/src/base/arenaFile.c @@ -19,12 +19,12 @@ #include "configFile.h" #include "image.h" #endif + #ifndef NO_SOUND #include "music.h" #endif static list_t *listArenaFile; - static bool_t isArenaFileInit = FALSE; bool_t isAreaFileInicialized() @@ -42,22 +42,20 @@ int getArenaValue(char *line, char *env, char *val, int len) strcpy(clone_env, " "); strcat(clone_env, env); - offset_env = strstr(line, clone_env); - if( offset_env == NULL )return -1; - + if (offset_env == NULL) + return -1; offset_val_begin = strchr(offset_env, '"'); - if( offset_val_begin == NULL )return -1; - + 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; - + 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; } @@ -68,10 +66,12 @@ static void cmd_arena(arena_t **arena, char *line) char str_w[STR_SIZE]; char str_h[STR_SIZE]; - 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; - + 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 (*arena)->background = getImage(IMAGE_GROUP_USER, str_image); @@ -79,15 +79,17 @@ static void cmd_arena(arena_t **arena, char *line) //(*arena)->w = atoi(str_w); //(*arena)->h = atoi(str_h); setCurrentArena(*arena); - printf("new arena\n"); +#ifndef DEBUG + printf(_("Loaded new arena...\n")); +#endif } static void cmd_loadModule(char *line) { char str_file[STR_SIZE]; - if( getArenaValue(line, "file", str_file, STR_SIZE) != 0 )return; - + if (getArenaValue(line, "file", str_file, STR_SIZE) != 0) + return; loadModule(str_file); } @@ -99,10 +101,12 @@ static void cmd_loadImage(char *line) char str_name[STR_SIZE]; char str_alpha[STR_SIZE]; - 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; - + 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); } @@ -111,9 +115,10 @@ static void cmd_loadMusic(char *line) char str_file[STR_SIZE]; char str_name[STR_SIZE]; - if( getArenaValue(line, "file", str_file, STR_SIZE) != 0 )return; - if( getArenaValue(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 @@ -123,11 +128,10 @@ static void cmd_playMusic(arena_t *arena, char *line) { char str_music[STR_SIZE]; - if( getArenaValue(line, "music", str_music, STR_SIZE) != 0 )return; - + if (getArenaValue(line, "music", str_music, STR_SIZE) != 0) + return; strcpy(arena->music, str_music); } - #endif int getArenaCount() @@ -143,18 +147,12 @@ static char *getArenaStatus(int id, char *s) ts = (textFile_t *) listArenaFile->list[id]; len = strlen(s); - - for( i = 0 ; i < ts->text->count ; i++ ) - { + for( i = 0; i < ts->text->count; i++ ) { char *line; line = (char *) (ts->text->list[i]); - if( strncmp(line, s, len) == 0 ) - { return line+len+1; - } } - return NULL; } @@ -163,7 +161,6 @@ char *getArenaName(int id) char *ret; ret = getArenaStatus(id, "name"); - return ( ret != NULL ? ret : "arena_no_name" ); } @@ -172,7 +169,6 @@ char *getArenaNetName(int id) char *ret; ret = getArenaStatus(id, "netName"); - return ( ret != NULL ? ret : "arena_no_net_name" ); } @@ -180,14 +176,9 @@ int getArenaIdFormNetName(char *s) { int i; - for( i = 0 ; i < listArenaFile->count ; i++ ) - { - if( strcmp(getArenaNetName(i), s) == 0 ) - { + for (i = 0; i < listArenaFile->count; i++) + if (strcmp(getArenaNetName(i), s) == 0) return i; - } - } - return -1; } @@ -203,27 +194,27 @@ arena_t* getArena(int id) int i; ts = (textFile_t *) listArenaFile->list[id]; - - for( i = 0 ; i < ts->text->count ; i++ ) - { + for( i = 0 ; i < ts->text->count ; i++ ) { char *line; - line = (char *) (ts->text->list[i]); + line = (char *) (ts->text->list[i]); cmdModule(line); - #ifndef PUBLIC_SERVER - if( strncmp(line, "loadImage", 9) == 0 )cmd_loadImage(line); - if( strncmp(line, "loadMusic", 9) == 0 )cmd_loadMusic(line); - if( strncmp(line, "playMusic", 9) == 0 )cmd_playMusic(arena, line); + if (strncmp(line, "loadImage", 9) == 0) + cmd_loadImage(line); + if (strncmp(line, "loadMusic", 9) == 0) + cmd_loadMusic(line); + if (strncmp(line, "playMusic", 9) == 0) + cmd_playMusic(arena, line); #endif - - if( strncmp(line, "arena", 5) == 0 )cmd_arena(&arena, line); - if( strncmp(line, "loadModule", 10) == 0 )cmd_loadModule(line); + if (strncmp(line, "arena", 5) == 0 ) + cmd_arena(&arena, line); + if (strncmp(line, "loadModule", 10) == 0 ) + cmd_loadModule(line); //if( strncmp(line, "wall", 4) == 0 )cmd_wall(arena, line); //if( strncmp(line, "teleport", 8) == 0 )cmd_teleport(arena, line); //if( strncmp(line, "pipe", 4) == 0 )cmd_pipe(arena, line); } - return arena; } @@ -235,33 +226,26 @@ void initArenaFile() #ifndef PUBLIC_SERVER assert( isImageInicialized() == TRUE ); #endif - isArenaFileInit = TRUE; listArenaFile = newList(); - p = loadDirector(PATH_ARENA); - - for( i = 0 ; i < p->list->count ; i++ ) - { + for (i = 0; i < p->list->count; i++) { char *line; line = (char *)( p->list->list[i] ); - - if( strstr(line, ".map") != NULL && strstr(line, "~") == NULL ) - { + if (strstr(line, ".map") != NULL && + strstr(line, "~") == NULL) { char path[STR_PATH_SIZE]; sprintf(path, PATH_ARENA "%s", line); - - printf("load map %s\n", line); - +#ifdef DEBUG + printf(_("Loading map file: %s\n"), line); +#endif accessExistFile(path); addList(listArenaFile, loadTextFile(path)); } } - //printf("No. of Arens: %d\n", listArenaFile->count); - destroyDirector(p); } @@ -270,4 +254,3 @@ void quitArenaFile() isArenaFileInit = FALSE; destroyListItem(listArenaFile, destroyTextFile); } - |