diff options
| author | Dusan Durech <dusan@debian.debian> | 2009-04-12 14:29:51 +0200 |
|---|---|---|
| committer | Dusan Durech <dusan@debian.debian> | 2009-04-12 14:29:51 +0200 |
| commit | 876fc624df9728ee0feee26e1b31b53ed9ef3326 (patch) | |
| tree | e20814ab6d07fb892284dcee11bc492532bdabaa /src | |
| parent | dff1cbc31ca8d585c01f5bebd08e50cf07fd2b0c (diff) | |
convert all name function from oldName to new_name
Diffstat (limited to 'src')
157 files changed, 3323 insertions, 3323 deletions
diff --git a/src/audio/audio.c b/src/audio/audio.c index 14297af..59e0cb1 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -12,7 +12,7 @@ static bool_t isAudioInit = FALSE; /* * Returns state of audio */ -bool_t isAudioInicialized() +bool_t audio_is_inicialized() { return isAudioInit; } @@ -20,7 +20,7 @@ bool_t isAudioInicialized() /* * Initialize audio */ -void initAudio() +void audio_init() { if (isParamFlag("--no-audio")) { return; @@ -49,7 +49,7 @@ void initAudio() /* * Quit audio */ -void quitAudio() +void audio_quit() { Mix_CloseAudio(); isAudioInit = TRUE; diff --git a/src/audio/audio.h b/src/audio/audio.h index 1f1f95b..65620e7 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -4,7 +4,7 @@ # include "main.h" -extern bool_t isAudioInicialized(); -extern void initAudio(); -extern void quitAudio(); +extern bool_t audio_is_inicialized(); +extern void audio_init(); +extern void audio_quit(); #endif diff --git a/src/audio/music.c b/src/audio/music.c index feabb90..1b526c6 100644 --- a/src/audio/music.c +++ b/src/audio/music.c @@ -13,13 +13,13 @@ static list_t *listStorage; static bool_t isMusicInit = FALSE; -static bool_t var_isMusicActive = TRUE; +static bool_t var_music_is_active = TRUE; static Mix_Music *currentMusic; /* * Return state of music initialization */ -bool_t isMusicInicialized() +bool_t music_is_inicialized() { return isMusicInit; } @@ -27,23 +27,23 @@ bool_t isMusicInicialized() /* * Initialize music */ -void initMusic() +void music_init() { - if (isAudioInicialized() == FALSE) { + if (audio_is_inicialized() == FALSE) { isMusicInit = FALSE; return; } - listStorage = newStorage(); + listStorage = storage_new(); currentMusic = NULL; isMusicInit = TRUE; - var_isMusicActive = TRUE; + var_music_is_active = TRUE; if (isParamFlag("--no-music")) - setMusicActive(FALSE); + music_set_active(FALSE); if (isParamFlag("--music")) - setMusicActive(TRUE); + music_set_active(TRUE); DEBUG_MSG(_("Initializing music\n")); } @@ -97,7 +97,7 @@ static void destroyMusic(void *p) /* * Add file to list with music */ -void addMusic(char *file, char *name, char *group) +void music_add(char *file, char *name, char *group) { Mix_Music *new; @@ -109,15 +109,15 @@ void addMusic(char *file, char *name, char *group) assert(group != NULL); new = loadMixMusic(file); - addItemToStorage(listStorage, group, name, new); + storage_add(listStorage, group, name, new); } /* * Disable music and stop playback */ -void stopMusic() +void music_stop() { - if (isMusicInit == FALSE || var_isMusicActive == FALSE) { + if (isMusicInit == FALSE || var_music_is_active == FALSE) { return; } @@ -132,7 +132,7 @@ void stopMusic() /* * Play music playback */ -void playMusic(char *name, char *group) +void music_play(char *name, char *group) { static char currentMusic_group[STR_SIZE]; static char currentMusic_name[STR_SIZE]; @@ -144,7 +144,7 @@ void playMusic(char *name, char *group) isStrInit = 1; } - if (isMusicInit == FALSE || var_isMusicActive == FALSE) + if (isMusicInit == FALSE || var_music_is_active == FALSE) return; if (currentMusic != NULL && @@ -154,10 +154,10 @@ void playMusic(char *name, char *group) } if (currentMusic != NULL) { - stopMusic(); + music_stop(); } - currentMusic = getItemFromStorage(listStorage, group, name); + currentMusic = storage_get(listStorage, group, name); strcpy(currentMusic_group, group); strcpy(currentMusic_name, name); @@ -171,34 +171,34 @@ void playMusic(char *name, char *group) /* * Set music status to active/inactive */ -void setMusicActive(bool_t n) +void music_set_active(bool_t n) { static Mix_Music *music = NULL; if (n == FALSE) { music = currentMusic; - stopMusic(); + music_stop(); } if (n == TRUE) { currentMusic = music; playMixMusic(); } - var_isMusicActive = n; + var_music_is_active = n; } /* * Return status of music */ -bool_t isMusicActive() +bool_t music_is_active() { - return var_isMusicActive; + return var_music_is_active; } /* * TOCOMMENT */ -char *getCurrentMusic() +char *music_get_current() { return "unknown"; } @@ -206,24 +206,24 @@ char *getCurrentMusic() /* * TOCOMMENT */ -void delAllMusicInGroup(char *group) +void music_del_all_in_group(char *group) { if (isMusicInit == FALSE) return; - delAllItemFromStorage(listStorage, group, destroyMusic); + storage_del_all(listStorage, group, destroyMusic); } /* * Deactivate all what is ment for music */ -void quitMusic() +void music_quit() { if (isMusicInit == FALSE) return; - stopMusic(); - destroyStorage(listStorage, destroyMusic); + music_stop(); + storage_destroy(listStorage, destroyMusic); isMusicInit = FALSE; DEBUG_MSG(_("Quitting music\n")); diff --git a/src/audio/music.h b/src/audio/music.h index 17e4409..cb5995d 100644 --- a/src/audio/music.h +++ b/src/audio/music.h @@ -17,15 +17,15 @@ } 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(); +extern bool_t music_is_inicialized(); +extern void music_init(); +extern void music_add(char *file, char *name, char *group); +extern void music_stop(); +extern void music_play(char *name, char *group); +extern void music_set_active(bool_t n); +extern bool_t music_is_active(); +extern char *music_get_current(); +extern void music_del_all_in_group(char *group); +extern void music_quit(); # endif #endif diff --git a/src/audio/sound.c b/src/audio/sound.c index dee6c2d..8d368a3 100644 --- a/src/audio/sound.c +++ b/src/audio/sound.c @@ -12,12 +12,12 @@ static list_t *listStorage; static bool_t isSoundInit = FALSE; -static bool_t var_isSoundActive = TRUE; +static bool_t var_sound_is_active = TRUE; /* * Return status of sound */ -bool_t isSoundInicialized() +bool_t sound_is_inicialized() { return isSoundInit; } @@ -25,22 +25,22 @@ bool_t isSoundInicialized() /* * Initialize sound */ -void initSound() +void sound_init() { - if (isAudioInicialized() == FALSE) { + if (audio_is_inicialized() == FALSE) { isSoundInit = FALSE; return; } - listStorage = newStorage(); + listStorage = storage_new(); isSoundInit = TRUE; - var_isSoundActive = TRUE; + var_sound_is_active = TRUE; if (isParamFlag("--no-sound")) - setSoundActive(FALSE); + sound_set_active(FALSE); if (isParamFlag("--sound")) - setSoundActive(TRUE); + sound_set_active(TRUE); DEBUG_MSG(_("Initializing sound\n")); @@ -90,7 +90,7 @@ static void destroySound(void *p) /* * Add sound to list */ -void addSound(char *file, char *name, char *group) +void sound_add(char *file, char *name, char *group) { Mix_Chunk *new; @@ -102,45 +102,45 @@ void addSound(char *file, char *name, char *group) assert(group != NULL); new = loadMixSound(file); - addItemToStorage(listStorage, group, name, new); + storage_add(listStorage, group, name, new); } /* * Start playback file from list */ -void playSound(char *name, char *group) +void sound_play(char *name, char *group) { - if (isSoundInit == FALSE || var_isSoundActive == FALSE) + if (isSoundInit == FALSE || var_sound_is_active == FALSE) return; - playMixSound(getItemFromStorage(listStorage, group, name)); + playMixSound(storage_get(listStorage, group, name)); } /* * Set if sound is active True/False */ -void setSoundActive(bool_t n) +void sound_set_active(bool_t n) { - var_isSoundActive = n; + var_sound_is_active = n; } /* * Return state of sound */ -bool_t isSoundActive() +bool_t sound_is_active() { - return var_isSoundActive; + return var_sound_is_active; } /* * Quit all sound stuff */ -void quitSound() +void sound_quit() { if (isSoundInit == FALSE) return; - destroyStorage(listStorage, destroySound); + storage_destroy(listStorage, destroySound); isSoundInit = FALSE; DEBUG_MSG(_("Quitting sound\n")); diff --git a/src/audio/sound.h b/src/audio/sound.h index a5d69d4..4c61bcd 100644 --- a/src/audio/sound.h +++ b/src/audio/sound.h @@ -17,12 +17,12 @@ } 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(); +extern bool_t sound_is_inicialized(); +extern void sound_init(); +extern void sound_add(char *file, char *name, char *group); +extern void sound_play(char *name, char *group); +extern void sound_set_active(bool_t n); +extern bool_t sound_is_active(); +extern void sound_quit(); # endif #endif diff --git a/src/base/archive.c b/src/base/archive.c index cbadae1..6aa6254 100644 --- a/src/base/archive.c +++ b/src/base/archive.c @@ -10,7 +10,7 @@ #define ARCHIVE_BUFFER_SIZE 4096 #define STR_TMP_FILE_NAME 4096 -char *extractFileFromArchive(char *archive, char *filename) +char *archive_extract_file(char *archive, char *filename) { char name[STR_TMP_FILE_NAME]; char buf[ARCHIVE_BUFFER_SIZE]; @@ -68,7 +68,7 @@ char *extractFileFromArchive(char *archive, char *filename) return strdup(name); } -void deleteExtractFile(char *s) +void archive_delete_file(char *s) { unlink(s); free(s); diff --git a/src/base/archive.h b/src/base/archive.h index 0817418..f7c2b46 100644 --- a/src/base/archive.h +++ b/src/base/archive.h @@ -3,7 +3,7 @@ # define ARCHIVE_H -extern char *extractFileFromArchive(char *archive, char *file); -extern void deleteExtractFile(char *s); +extern char *archive_extract_file(char *archive, char *file); +extern void archive_delete_file(char *s); #endif diff --git a/src/base/arena.c b/src/base/arena.c index effbff4..e58f8f3 100644 --- a/src/base/arena.c +++ b/src/base/arena.c @@ -43,12 +43,12 @@ static int isTuxNear(tux_t * tux1, tux_t * tux2) } #endif -void setCurrentArena(arena_t * p) +void arena_set_current(arena_t * p) { currentArena = p; } -arena_t *getCurrentArena() +arena_t *arena_get_current() { return currentArena; } @@ -63,7 +63,7 @@ void hotkey_splitArena() } #ifndef PUBLIC_SERVER -void initArena() +void arena_init() { splitType = SCREEN_SPLIT_VERTICAL; @@ -77,16 +77,16 @@ void initArena() printf("SCREEN_SPLIT_HORIZONTAL\n"); } - registerHotKey(SDLK_F3, hotkey_splitArena); + hotKey_register(SDLK_F3, hotkey_splitArena); } -void quitArena() +void arena_quit() { - unregisterHotKey(SDLK_F3); + unhotKey_register(SDLK_F3); } #endif -arena_t *newArena(int w, int h) +arena_t *arena_new(int w, int h) { arena_t *new; int zone_w, zone_h; @@ -101,7 +101,7 @@ arena_t *newArena(int w, int h) new->w = w; new->h = h; - new->listTimer = newList(); + new->listTimer = list_new(); if (w > 800 || h > 600) { zone_w = 320; @@ -111,9 +111,9 @@ arena_t *newArena(int w, int h) zone_h = 60; } - new->spaceTux = newSpace(w, h, zone_w, zone_h, getStatusTux, setStatusTux); - new->spaceItem = newSpace(w, h, zone_w, zone_h, getStatusItem, setStatusItem); - new->spaceShot = newSpace(w, h, zone_w, zone_h, getStatusShot, setStatusShot); + new->spaceTux = space_new(w, h, zone_w, zone_h, tux_get_status, tux_set_status); + new->spaceItem = space_new(w, h, zone_w, zone_h, item_get_status, item_set_status); + new->spaceShot = space_new(w, h, zone_w, zone_h, shot_get_status, shot_set_status); new->countRound = 0; new->max_countRound = 0; @@ -122,36 +122,36 @@ arena_t *newArena(int w, int h) } int -conflictSpace(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) +arena_conflict_space(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { return (x1 < x2 + w2 && x2 < x1 + w1 && y1 < y2 + h2 && y2 < y1 + h1); } -int isFreeSpace(arena_t * arena, int x, int y, int w, int h) +int arena__is_free_space(arena_t * arena, int x, int y, int w, int h) { if (x < 0 || y < 0 || x + w > arena->w || y + h > arena->h) { return 0; } - if (isConflictWithObjectFromSpace(arena->spaceTux, x, y, w, h)) + if (space_is_conflict_with_object(arena->spaceTux, x, y, w, h)) return 0; - if (isConflictWithObjectFromSpace(arena->spaceShot, x, y, w, h)) + if (space_is_conflict_with_object(arena->spaceShot, x, y, w, h)) return 0; - if (isConflictWithObjectFromSpace(arena->spaceItem, x, y, w, h)) + if (space_is_conflict_with_object(arena->spaceItem, x, y, w, h)) return 0; - if (isConflictWithObjectFromSpace(arena->spaceShot, x, y, w, h)) + if (space_is_conflict_with_object(arena->spaceShot, x, y, w, h)) return 0; - if (isConflictModule(x, y, w, h)) + if (module_is_conflict(x, y, w, h)) return 0; return 1; } -void findFreeSpace(arena_t * arena, int *x, int *y, int w, int h) +void arena_find_free_space(arena_t * arena, int *x, int *y, int w, int h) { int z_x; int z_y; @@ -162,17 +162,17 @@ void findFreeSpace(arena_t * arena, int *x, int *y, int w, int h) do { z_x = random() % (arena->w - w); z_y = random() % (arena->h - h); - } while (isFreeSpace(arena, z_x, z_y, w, h) == 0); + } while (arena__is_free_space(arena, z_x, z_y, w, h) == 0); *x = z_x; *y = z_y; } -void getCenterScreen(int *screen_x, int *screen_y, int x, int y, int screen_size_x, int screen_size_y) +void arena_get_center_screen(int *screen_x, int *screen_y, int x, int y, int screen_size_x, int screen_size_y) { arena_t *arena; - arena = getCurrentArena(); + arena = arena_get_current(); *screen_x = x - screen_size_x / 2; *screen_y = y - screen_size_y / 2; @@ -220,28 +220,28 @@ static void drawBackground(arena_t * arena, int screen_x, int screen_y) } } -static void action_drawTux(space_t * space, tux_t * tux, void *p) +static void action_tux_draw(space_t * space, tux_t * tux, void *p) { - drawTux(tux); + tux_draw(tux); } -static void action_drawItem(space_t * space, item_t * item, void *p) +static void action_item_draw(space_t * space, item_t * item, void *p) { - drawItem(item); + item_draw(item); } -static void action_drawShot(space_t * space, shot_t * shot, void *p) +static void action_shot_draw(space_t * space, shot_t * shot, void *p) { - drawShot(shot); + shot_draw(shot); } static void drawObjects(arena_t * arena, int screen_x, int screen_y) { - actionSpaceFromLocation(arena->spaceTux, action_drawTux, NULL, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); - actionSpaceFromLocation(arena->spaceItem, action_drawItem, NULL, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); - actionSpaceFromLocation(arena->spaceShot, action_drawShot, NULL, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); + space_action_from_location(arena->spaceTux, action_tux_draw, NULL, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); + space_action_from_location(arena->spaceItem, action_item_draw, NULL, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); + space_action_from_location(arena->spaceShot, action_shot_draw, NULL, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); - drawModule(screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); + module_draw(screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); } static void drawSplitArenaForTux(arena_t * arena, tux_t * tux, int location_x, int location_y) @@ -250,10 +250,10 @@ static void drawSplitArenaForTux(arena_t * arena, tux_t * tux, int location_x, i switch (splitType) { case SCREEN_SPLIT_HORIZONTAL: - getCenterScreen(&screen_x, &screen_y, tux->x, tux->y, WINDOW_SIZE_X, WINDOW_SIZE_Y / 2); + arena_get_center_screen(&screen_x, &screen_y, tux->x, tux->y, WINDOW_SIZE_X, WINDOW_SIZE_Y / 2); break; case SCREEN_SPLIT_VERTICAL: - getCenterScreen(&screen_x, &screen_y, tux->x, tux->y, WINDOW_SIZE_X / 2, WINDOW_SIZE_Y); + arena_get_center_screen(&screen_x, &screen_y, tux->x, tux->y, WINDOW_SIZE_X / 2, WINDOW_SIZE_Y); break; default: screen_x = -1; @@ -267,10 +267,10 @@ static void drawSplitArenaForTux(arena_t * arena, tux_t * tux, int location_x, i switch (splitType) { case SCREEN_SPLIT_HORIZONTAL: - drawLayerSplit(location_x, location_y, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y / 2); + layer_draw_slpit(location_x, location_y, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y / 2); break; case SCREEN_SPLIT_VERTICAL: - drawLayerSplit(location_x, location_y, screen_x, screen_y, WINDOW_SIZE_X / 2, WINDOW_SIZE_Y); + layer_draw_slpit(location_x, location_y, screen_x, screen_y, WINDOW_SIZE_X / 2, WINDOW_SIZE_Y); break; default: screen_x = -1; @@ -284,7 +284,7 @@ void drawSplitArena(arena_t * arena) { tux_t *tux = NULL; - tux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT); + tux = word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT); if (tux != NULL) { switch (splitType) { @@ -297,7 +297,7 @@ void drawSplitArena(arena_t * arena) } } - tux = getControlTux(TUX_CONTROL_KEYBOARD_LEFT); + tux = word_get_control_tux(TUX_CONTROL_KEYBOARD_LEFT); if (tux != NULL) { drawSplitArenaForTux(arena, tux, 0, 0); @@ -308,10 +308,10 @@ void drawCenterArena(arena_t * arena, int x, int y) { int screen_x, screen_y; - getCenterScreen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y); + arena_get_center_screen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y); drawBackground(arena, screen_x, screen_y); drawObjects(arena, screen_x, screen_y); - drawLayerCenter(x, y); + layer_draw_center(x, y); } void drawSimpleArena(arena_t * arena) @@ -319,7 +319,7 @@ void drawSimpleArena(arena_t * arena) int screen_x, screen_y; tux_t *tux = NULL; - tux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT); + tux = word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT); if (tux == NULL) { return; @@ -330,18 +330,18 @@ void drawSimpleArena(arena_t * arena) drawBackground(arena, screen_x, screen_y); drawObjects(arena, screen_x, screen_y); - drawLayer(tux->x, tux->y); + layer_draw_all(tux->x, tux->y); } -void drawArena(arena_t * arena) +void arena_draw(arena_t * arena) { if (isBigArena(arena) && - getNetTypeGame() == NET_GAME_TYPE_NONE && !isSettingAI()) { + netMultiplayer_get_game_type() == NET_GAME_TYPE_NONE && !setting_is_ai()) { tux_t *tux1; tux_t *tux2; - tux1 = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT); - tux2 = getControlTux(TUX_CONTROL_KEYBOARD_LEFT); + tux1 = word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT); + tux2 = word_get_control_tux(TUX_CONTROL_KEYBOARD_LEFT); if (isTuxNear(tux1, tux2)) { drawCenterArena(arena, (tux1->x + tux2->x) / 2, (tux1->y + tux2->y) / 2); @@ -355,7 +355,7 @@ void drawArena(arena_t * arena) if (isBigArena(arena)) { tux_t *tux = NULL; - tux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT); + tux = word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT); if (tux == NULL) { return; @@ -372,35 +372,35 @@ void drawArena(arena_t * arena) static void action_tux(space_t * space, tux_t * tux, void *p) { - eventTux(tux); + tux_event(tux); } -void eventArena(arena_t * arena) +void arena_event(arena_t * arena) { int i; for (i = 0; i < 8; i++) { - checkShotIsInTuxScreen(arena); + shot_check_is_tux_screen(arena); - eventConflictShotWithItem(arena); - eventConflictTuxWithShot(arena); - eventModule(); + item_event_conglicts_shot_with_item(arena); + tux_conflict_woth_shot(arena); + module_event(); - eventMoveListShot(arena); + shot_event_move_list(arena); } - eventListItem(arena->spaceItem); + item_event(arena->spaceItem); - actionSpace(arena->spaceTux, action_tux, NULL); + space_action(arena->spaceTux, action_tux, NULL); - eventTimer(arena->listTimer); + timer_event(arena->listTimer); } -void destroyArena(arena_t * p) +void arena_destroy(arena_t * p) { - destroySpaceWithObject(p->spaceTux, destroyTux); - destroySpaceWithObject(p->spaceItem, destroyItem); - destroySpaceWithObject(p->spaceShot, destroyShot); - destroyTimer(p->listTimer); + space_destroy_with_item(p->spaceTux, tux_destroy); + space_destroy_with_item(p->spaceItem, item_destroy); + space_destroy_with_item(p->spaceShot, shot_destroy); + timer_destroy(p->listTimer); free(p); } diff --git a/src/base/arena.h b/src/base/arena.h index 14f0f1f..fbbaede 100644 --- a/src/base/arena.h +++ b/src/base/arena.h @@ -38,21 +38,21 @@ typedef struct arena_struct { } arena_t; -extern void setCurrentArena(arena_t * p); -extern arena_t *getCurrentArena(); -extern void initArena(); -extern void quitArena(); -extern arena_t *newArena(int w, int h); -extern int conflictSpace(int x1, int y1, int w1, int h1, int x2, int y2, +extern void arena_set_current(arena_t * p); +extern arena_t *arena_get_current(); +extern void arena_init(); +extern void arena_quit(); +extern arena_t *arena_new(int w, int h); +extern int arena_conflict_space(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, +extern int arena__is_free_space(arena_t * arena, int x, int y, int w, int h); +extern void arena_find_free_space(arena_t * arena, int *x, int *y, int w, int h); +extern void arena_get_center_screen(int *screen_x, int *screen_y, int x, int y, int screen_size_x, int screen_size_y); # ifndef PUBLIC_SERVER -extern void drawArena(arena_t * arena); +extern void arena_draw(arena_t * arena); # endif -extern void eventArena(arena_t * arena); -extern void destroyArena(arena_t * p); +extern void arena_event(arena_t * arena); +extern void arena_destroy(arena_t * p); #endif diff --git a/src/base/arenaFile.c b/src/base/arenaFile.c index 2f58513..a5fa709 100644 --- a/src/base/arenaFile.c +++ b/src/base/arenaFile.c @@ -29,12 +29,12 @@ static list_t *listArenaFile; static bool_t isArenaFileInit = FALSE; -bool_t isAreaFileInicialized() +bool_t arenaFile_is_inicialized() { return isArenaFileInit; } -int getArenaValue(char *line, char *env, char *val, int len) +int arenaFile_get_value(char *line, char *env, char *val, int len) { char *offset_env; char *offset_val_begin; @@ -73,14 +73,14 @@ int getArenaValue(char *line, char *env, char *val, int len) #ifndef PUBLIC_SERVER -image_t *loadImageFromArena(arenaFile_t * arenaFile, char *filename, char *group, char *name, int alpha) +image_t *arenaFile_load_image(arenaFile_t * arenaFile, char *filename, char *group, char *name, int alpha) { char *extractFile; image_t *image; - extractFile = extractFileFromArchive(arenaFile->path, filename); - image = addImageData(extractFile, alpha, name, group); - deleteExtractFile(extractFile); + extractFile = archive_extract_file(arenaFile->path, filename); + image = image_add(extractFile, alpha, name, group); + archive_delete_file(extractFile); return image; } @@ -90,9 +90,9 @@ void loadMusicFromArena(arenaFile_t * arenaFile, char *filename, char *group, ch { char *extractFile; - extractFile = extractFileFromArchive(arenaFile->path, filename); - addMusic(extractFile, name, group); - deleteExtractFile(extractFile); + extractFile = archive_extract_file(arenaFile->path, filename); + music_add(extractFile, name, group); + archive_delete_file(extractFile); } #endif #endif @@ -103,34 +103,34 @@ 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) + if (arenaFile_get_value(line, "background", str_image, STR_SIZE) != 0) return; - if (getArenaValue(line, "w", str_w, STR_SIZE) != 0) + if (arenaFile_get_value(line, "w", str_w, STR_SIZE) != 0) return; - if (getArenaValue(line, "h", str_h, STR_SIZE) != 0) + if (arenaFile_get_value(line, "h", str_h, STR_SIZE) != 0) return; - (*arena) = newArena(atoi(str_w), atoi(str_h)); + (*arena) = arena_new(atoi(str_w), atoi(str_h)); #ifndef PUBLIC_SERVER - (*arena)->background = getImage(IMAGE_GROUP_USER, str_image); + (*arena)->background = image_get(IMAGE_GROUP_USER, str_image); #endif //(*arena)->w = atoi(str_w); //(*arena)->h = atoi(str_h); - setCurrentArena(*arena); + arena_set_current(*arena); DEBUG_MSG(_("Loaded new arena...\n")); } -static void cmd_loadModule(char *line) +static void cmd_module_load(char *line) { char str_file[STR_SIZE]; - if (getArenaValue(line, "file", str_file, STR_SIZE) != 0) + if (arenaFile_get_value(line, "file", str_file, STR_SIZE) != 0) return; - loadModule(str_file); + module_load(str_file); } #ifndef PUBLIC_SERVER @@ -141,19 +141,19 @@ static void cmd_loadImage(arenaFile_t * arenaFile, char *line) char str_name[STR_SIZE]; char str_alpha[STR_SIZE]; - if (getArenaValue(line, "file", str_file, STR_SIZE) != 0) + if (arenaFile_get_value(line, "file", str_file, STR_SIZE) != 0) return; - if (getArenaValue(line, "name", str_name, STR_SIZE) != 0) + if (arenaFile_get_value(line, "name", str_name, STR_SIZE) != 0) return; - if (getArenaValue(line, "alpha", str_alpha, STR_SIZE) != 0) + if (arenaFile_get_value(line, "alpha", str_alpha, STR_SIZE) != 0) return; //printf("str_file=%s str_name=%s str_alpha=%s\n", str_file, str_name, str_alpha); - loadImageFromArena(arenaFile, str_file, IMAGE_GROUP_USER, str_name, isYesOrNO(str_alpha)); + arenaFile_load_image(arenaFile, str_file, IMAGE_GROUP_USER, str_name, isYesOrNO(str_alpha)); - //addImageData(str_file, isYesOrNO(str_alpha), str_name, IMAGE_GROUP_USER); + //image_add(str_file, isYesOrNO(str_alpha), str_name, IMAGE_GROUP_USER); } static void cmd_loadMusic(arenaFile_t * arenaFile, char *line) @@ -161,35 +161,35 @@ static void cmd_loadMusic(arenaFile_t * arenaFile, char *line) char str_file[STR_SIZE]; char str_name[STR_SIZE]; - if (getArenaValue(line, "file", str_file, STR_SIZE) != 0) + if (arenaFile_get_value(line, "file", str_file, STR_SIZE) != 0) return; - if (getArenaValue(line, "name", str_name, STR_SIZE) != 0) + if (arenaFile_get_value(line, "name", str_name, STR_SIZE) != 0) return; #ifndef NO_SOUND - //addMusic(str_file, str_name, MUSIC_GROUP_USER); + //music_add(str_file, str_name, MUSIC_GROUP_USER); loadMusicFromArena(arenaFile, str_file, MUSIC_GROUP_USER, str_name); #endif } -static void cmd_playMusic(arena_t * arena, char *line) +static void cmd_music_play(arena_t * arena, char *line) { char str_music[STR_SIZE]; - if (getArenaValue(line, "music", str_music, STR_SIZE) != 0) + if (arenaFile_get_value(line, "music", str_music, STR_SIZE) != 0) return; strcpy(arena->music, str_music); } #endif -int getArenaCount() +int arenaFile_get_count() { return listArenaFile->count; } -static char *getArenaStatus(textFile_t * ts, char *s) +static char *arenaFile_get_arenaStatus(textFile_t * ts, char *s) { int len; int i; @@ -208,23 +208,23 @@ static char *getArenaStatus(textFile_t * ts, char *s) return NULL; } -char *getArenaName(arenaFile_t * arenaFile) +char *arenaFile_get_name(arenaFile_t * arenaFile) { char *ret; - ret = getArenaStatus(arenaFile->map, "name"); + ret = arenaFile_get_arenaStatus(arenaFile->map, "name"); return (ret != NULL ? ret : "arena_no_name"); } -char *getArenaNetName(arenaFile_t * arenaFile) +char *arenaFile_get_net_name(arenaFile_t * arenaFile) { char *ret; - ret = getArenaStatus(arenaFile->map, "netName"); + ret = arenaFile_get_arenaStatus(arenaFile->map, "netName"); return (ret != NULL ? ret : "arena_no_net_name"); } -arenaFile_t *getArenaFileFormNetName(char *s) +arenaFile_t *arenaFile_get_file_format_net_name(char *s) { int i; @@ -233,24 +233,24 @@ arenaFile_t *getArenaFileFormNetName(char *s) arenaFile = (arenaFile_t *) listArenaFile->list[i]; - if (strcmp(getArenaNetName(arenaFile), s) == 0) + if (strcmp(arenaFile_get_net_name(arenaFile), s) == 0) return arenaFile; } return NULL; } -char *getArenaImage(arenaFile_t * arenaFile) +char *arenaFile_get_image(arenaFile_t * arenaFile) { - return getArenaStatus(arenaFile->map, "screen"); + return arenaFile_get_arenaStatus(arenaFile->map, "screen"); } -arenaFile_t *getArenaFile(int n) +arenaFile_t *arenaFile_get(int n) { return (arenaFile_t *) listArenaFile->list[n]; } -int getArenaFileID(arenaFile_t * arenaFile) +int arenaFile_get_id(arenaFile_t * arenaFile) { int i; @@ -267,7 +267,7 @@ int getArenaFileID(arenaFile_t * arenaFile) return -1; } -arena_t *getArena(arenaFile_t * arenaFile) +arena_t *arenaFile_get_arena(arenaFile_t * arenaFile) { textFile_t *ts; arena_t *arena = NULL; // no warninng @@ -279,7 +279,7 @@ arena_t *getArena(arenaFile_t * arenaFile) char *line; line = (char *) (ts->text->list[i]); - cmdModule(line); + module_cmd(line); #ifndef PUBLIC_SERVER if (strncmp(line, "loadImage", 9) == 0) cmd_loadImage(arenaFile, line); @@ -288,20 +288,20 @@ arena_t *getArena(arenaFile_t * arenaFile) cmd_loadMusic(arenaFile, line); if (strncmp(line, "playMusic", 9) == 0) - cmd_playMusic(arena, line); + cmd_music_play(arena, line); #endif if (strncmp(line, "arena", 5) == 0) cmd_arena(&arena, line); if (strncmp(line, "loadModule", 10) == 0) - cmd_loadModule(line); + cmd_module_load(line); } return arena; } -arenaFile_t *newArenaFile(char *path) +arenaFile_t *arenaFile_new(char *path) { arenaFile_t *new; char *extractFile; @@ -309,32 +309,32 @@ arenaFile_t *newArenaFile(char *path) new = malloc(sizeof(arenaFile_t)); new->path = strdup(path); - extractFile = extractFileFromArchive(path, "arena.map"); - new->map = loadTextFile(extractFile); - deleteExtractFile(extractFile); + extractFile = archive_extract_file(path, "arena.map"); + new->map = textFile_load(extractFile); + archive_delete_file(extractFile); return new; } -void destroyArenaFile(arenaFile_t * p) +void arena_destroyFile(arenaFile_t * p) { - destroyTextFile(p->map); + textFile_destroy(p->map); free(p->path); free(p); } -void loadArenaFile(char *path) +void arenaFile_load(char *path) { - addList(listArenaFile, newArenaFile(path)); + list_add(listArenaFile, arenaFile_new(path)); } -static void loadArenaFromDirector(char *director) +static void load_arenaFromDirector(char *director) { director_t *p; int i; DEBUG_MSG(_("Loading arena files from %s\n"), director); - p = loadDirector(director); + p = director_load(director); if (p==NULL) { @@ -360,32 +360,32 @@ static void loadArenaFromDirector(char *director) DEBUG_MSG(_("Loading arena: %s\n"), line); accessExistFile(path); - loadArenaFile(path); + arenaFile_load(path); } } //printf("No. of Arens: %d\n", listArenaFile->count); - destroyDirector(p); + director_destroy(p); } -void initArenaFile() +void arenaFile_init() { #ifndef PUBLIC_SERVER - assert(isImageInicialized() == TRUE); + assert(image_is_inicialized() == TRUE); #endif isArenaFileInit = TRUE; - listArenaFile = newList(); + listArenaFile = list_new(); - loadArenaFromDirector(PATH_ARENA); + load_arenaFromDirector(PATH_ARENA); #ifndef PUBLIC_SERVER - loadArenaFromDirector(getHomeDirector()); + load_arenaFromDirector(homeDirector_get()); #endif } -void quitArenaFile() +void arenaFile_quit() { isArenaFileInit = FALSE; - destroyListItem(listArenaFile, destroyArenaFile); + list_destroy_item(listArenaFile, arena_destroyFile); } diff --git a/src/base/arenaFile.h b/src/base/arenaFile.h index 05728d4..d146664 100644 --- a/src/base/arenaFile.h +++ b/src/base/arenaFile.h @@ -13,23 +13,23 @@ typedef struct { textFile_t *map; } arenaFile_t; -extern bool_t isAreaFileInicialized(); -extern int getArenaValue(char *line, char *env, char *val, int len); -extern int getArenaCount(); -extern char *getArenaName(arenaFile_t * arenaFile); -extern char *getArenaNetName(arenaFile_t * arenaFile); -extern arenaFile_t *getArenaFileFormNetName(char *s); -extern char *getArenaImage(arenaFile_t * arenaFile); +extern bool_t arenaFile_is_inicialized(); +extern int arenaFile_get_value(char *line, char *env, char *val, int len); +extern int arenaFile_get_count(); +extern char *arenaFile_get_name(arenaFile_t * arenaFile); +extern char *arenaFile_get_net_name(arenaFile_t * arenaFile); +extern arenaFile_t *arenaFile_get_file_format_net_name(char *s); +extern char *arenaFile_get_image(arenaFile_t * arenaFile); # ifndef PUBLIC_SERVER -extern image_t *loadImageFromArena(arenaFile_t * arenaFile, char *filename, +extern image_t *arenaFile_load_image(arenaFile_t * arenaFile, char *filename, char *group, char *name, int alpha); # endif -extern arenaFile_t *getArenaFile(int n); -extern int getArenaFileID(arenaFile_t * arenaFile); -extern arena_t *getArena(arenaFile_t * arenaFile); -extern arenaFile_t *newArenaFile(char *path); -extern void loadArenaFile(char *path); -extern void initArenaFile(); -extern void quitArenaFile(); +extern arenaFile_t *arenaFile_get(int n); +extern int arenaFile_get_id(arenaFile_t * arenaFile); +extern arena_t *arenaFile_get_arena(arenaFile_t * arenaFile); +extern arenaFile_t *arenaFile_new(char *path); +extern void arenaFile_load(char *path); +extern void arenaFile_init(); +extern void arenaFile_quit(); #endif diff --git a/src/base/buffer.c b/src/base/buffer.c index 6e771db..a78bb14 100644 --- a/src/base/buffer.c +++ b/src/base/buffer.c @@ -6,7 +6,7 @@ #include "buffer.h" -buffer_t *newBuffer(int n) +buffer_t *buffer_new(int n) { buffer_t *new; @@ -19,17 +19,17 @@ buffer_t *newBuffer(int n) return new; } -void *getBufferData(buffer_t * p) +void *buffer_get_data(buffer_t * p) { return p->data; } -int getBufferSize(buffer_t * p) +int buffer_get_size(buffer_t * p) { return p->size; } -int addBuffer(buffer_t * p, char *data, int len) +int buffer_append(buffer_t * p, char *data, int len) { assert(p != NULL); assert(data != NULL); @@ -44,7 +44,7 @@ int addBuffer(buffer_t * p, char *data, int len) return -1; } -int cutBuffer(buffer_t * p, int len) +int buffer_cut(buffer_t * p, int len) { assert(p != NULL); assert(len >= 0); @@ -58,7 +58,7 @@ int cutBuffer(buffer_t * p, int len) return -1; } -int getBufferCount(buffer_t * p) +int buffer_count_line(buffer_t * p) { char *begin; char *end; @@ -82,7 +82,7 @@ int getBufferCount(buffer_t * p) return count; } -int getBufferLine(buffer_t * p, char *line, int len) +int buffer_get_line(buffer_t * p, char *line, int len) { char *end; int ret_len; @@ -105,12 +105,12 @@ int getBufferLine(buffer_t * p, char *line, int len) memset(line, 0, len); memcpy(line, p->data, ret_len); - cutBuffer(p, ret_len); + buffer_cut(p, ret_len); return ret_len; } -int getBufferDataLen(buffer_t * p, char *line, int len) +int buffer_get_data_len(buffer_t * p, char *line, int len) { assert(p != NULL); assert(line != NULL); @@ -121,12 +121,12 @@ int getBufferDataLen(buffer_t * p, char *line, int len) } memcpy(line, p->data, len); - cutBuffer(p, len); + buffer_cut(p, len); return len; } -void destroyBuffer(buffer_t * p) +void buffer_destroy(buffer_t * p) { assert(p != NULL); diff --git a/src/base/buffer.h b/src/base/buffer.h index a5f9717..1aabfc7 100644 --- a/src/base/buffer.h +++ b/src/base/buffer.h @@ -11,14 +11,14 @@ typedef struct str_buffer { unsigned int alloc; } buffer_t; -extern buffer_t *newBuffer(int n); -extern void *getBufferData(buffer_t * p); -extern int getBufferSize(buffer_t * p); -extern int addBuffer(buffer_t * p, char *data, int len); -extern int cutBuffer(buffer_t * p, int len); -extern int getBufferCount(buffer_t * p); -extern int getBufferLine(buffer_t * p, char *line, int len); -extern int getBufferDataLen(buffer_t * p, char *line, int len); -extern void destroyBuffer(buffer_t * p); +extern buffer_t *buffer_new(int n); +extern void *buffer_get_data(buffer_t * p); +extern int buffer_get_size(buffer_t * p); +extern int buffer_append(buffer_t * p, char *data, int len); +extern int buffer_cut(buffer_t * p, int len); +extern int buffer_count_line(buffer_t * p); +extern int buffer_get_line(buffer_t * p, char *line, int len); +extern int buffer_get_data_len(buffer_t * p, char *line, int len); +extern void buffer_destroy(buffer_t * p); #endif diff --git a/src/base/checkFront.c b/src/base/checkFront.c index 571cdd3..846c3a6 100644 --- a/src/base/checkFront.c +++ b/src/base/checkFront.c @@ -28,7 +28,7 @@ static checkfront_t *newCheck(char *s, int type, int id) new = malloc(sizeof(checkfront_t)); memset(new, 0, sizeof(checkfront_t)); new->msg = strdup(s); - new->time = getMyTime(); + new->time = timer_get_current_time(); new->id = id; new->type = type; new->count = 0; @@ -43,25 +43,25 @@ static void destroyCheck(checkfront_t * p) free(p); } -list_t *newCheckFront() +list_t *checkFront_new() { - return newList(); + return list_new(); } -void addMsgInCheckFront(list_t * list, char *msg, int type, int id) +void checkFront_add_msg(list_t * list, char *msg, int type, int id) { if (type == CHECK_FRONT_TYPE_CHECK) - incID(id); + id_inc(id); - addList(list, newCheck(msg, type, id)); + list_add(list, newCheck(msg, type, id)); } -void eventMsgInCheckFront(client_t * client) +void checkFront_event(client_t * client) { my_time_t currentTime; int i; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); for (i = 0; i < client->listSendMsg->count; i++) { checkfront_t *this; @@ -70,19 +70,19 @@ void eventMsgInCheckFront(client_t * client) switch (this->type) { case CHECK_FRONT_TYPE_SIMPLE: - sendClient(client, this->msg); - delListItem(client->listSendMsg, i, destroyCheck); + server_send_client(client, this->msg); + list_del_item(client->listSendMsg, i, destroyCheck); i--; break; case CHECK_FRONT_TYPE_CHECK: if (this->count == 0 || currentTime - this->time > CHECK_FRONT_SEND_TIME_INTERVAL) { - sendClient(client, this->msg); + server_send_client(client, this->msg); this->time = currentTime; this->count++; } if (this->count > CHECK_FRONT_MAX_COUNT_SEND) { - delID(this->id); - delListItem(client->listSendMsg, i, destroyCheck); + id_del(this->id); + list_del_item(client->listSendMsg, i, destroyCheck); i--; } break; @@ -93,7 +93,7 @@ void eventMsgInCheckFront(client_t * client) } } -void delMsgInCheckFront(list_t * listCheckFront, int id) +void checkFront_del_msg(list_t * listCheckFront, int id) { int i; @@ -103,15 +103,15 @@ void delMsgInCheckFront(list_t * listCheckFront, int id) this = (checkfront_t *) listCheckFront->list[i]; if (this->id == id) { - delID(this->id); - delListItem(listCheckFront, i, destroyCheck); + id_del(this->id); + list_del_item(listCheckFront, i, destroyCheck); return; } } } -void destroyCheckFront(list_t * p) +void checkFront_destroy(list_t * p) { assert(p != NULL); - destroyListItem(p, destroyCheck); + list_destroy_item(p, destroyCheck); } diff --git a/src/base/checkFront.h b/src/base/checkFront.h index 85ed2fb..4e7781d 100644 --- a/src/base/checkFront.h +++ b/src/base/checkFront.h @@ -12,10 +12,10 @@ # include "list.h" # include "server.h" -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); +extern list_t *checkFront_new(); +extern void checkFront_add_msg(list_t * list, char *msg, int type, int id); +extern void checkFront_event(client_t * client); +extern void checkFront_del_msg(list_t * listCheckFront, int id); +extern void checkFront_destroy(list_t * p); #endif diff --git a/src/base/director.c b/src/base/director.c index 49522de..2e6a24a 100644 --- a/src/base/director.c +++ b/src/base/director.c @@ -15,7 +15,7 @@ typedef struct director_struct { list_t *list; } director_t; -director_t *loadDirector(char *s) +director_t *director_load(char *s) { director_t *new; DIR *dir; @@ -27,7 +27,7 @@ director_t *loadDirector(char *s) new = malloc(sizeof(director_t)); memset(new, 0, sizeof(director_t)); - new->list = newList(); + new->list = list_new(); #ifndef __WIN32__ if (s[0] == '/') @@ -53,18 +53,18 @@ director_t *loadDirector(char *s) } while ((item = readdir(dir)) != NULL) - addList(new->list, strdup(item->d_name)); + list_add(new->list, strdup(item->d_name)); closedir(dir); return new; } -void destroyDirector(director_t * p) +void director_destroy(director_t * p) { assert(p != NULL); - destroyListItem(p->list, free); + list_destroy_item(p->list, free); free(p->path); free(p); } diff --git a/src/base/director.h b/src/base/director.h index ea61dd0..5eb2a9c 100644 --- a/src/base/director.h +++ b/src/base/director.h @@ -10,6 +10,6 @@ typedef struct director_struct { list_t *list; } director_t; -extern director_t *loadDirector(char *s); -extern void destroyDirector(director_t * p); +extern director_t *director_load(char *s); +extern void director_destroy(director_t * p); #endif diff --git a/src/base/downServer.c b/src/base/downServer.c index 46307cb..8575fa5 100644 --- a/src/base/downServer.c +++ b/src/base/downServer.c @@ -65,12 +65,12 @@ static void proto_getarena(client_ds_t *client, char *msg) arenaName = msg+9; //printf("arena = >>%s<<\n", arenaName); - arenaFile = getArenaFileFormNetName(arenaName); + arenaFile = arenaFile_get_file_format_net_name(arenaName); if( arenaFile == NULL ) { char *error_msg = _("ERR Arena not found !\n"); - addBuffer(client->sendBuffer, error_msg, strlen(error_msg)); + buffer_append(client->sendBuffer, error_msg, strlen(error_msg)); return; } @@ -79,13 +79,13 @@ static void proto_getarena(client_ds_t *client, char *msg) if( client->file == NULL ) { char *error_msg = _("ERR Server has a problem !\n"); - addBuffer(client->sendBuffer, error_msg, strlen(error_msg)); + buffer_append(client->sendBuffer, error_msg, strlen(error_msg)); return; } client->size = getFileSize(arenaFile->path); sprintf(msg_out, "OK %d\n", client->size); - addBuffer(client->sendBuffer, msg_out, strlen(msg_out)); + buffer_append(client->sendBuffer, msg_out, strlen(msg_out)); } static void do_proto(client_ds_t *client, char *msg) @@ -105,17 +105,17 @@ static client_ds_t* newClient(sock_tcp_t *sock) new->status_connect = NET_STATUS_OK; new->sock = sock; - new->recvBuffer = newBuffer(DOWN_SERVER_LIMIT_BUFFER); - new->sendBuffer = newBuffer(DOWN_SERVER_LIMIT_BUFFER); + new->recvBuffer = buffer_new(DOWN_SERVER_LIMIT_BUFFER); + new->sendBuffer = buffer_new(DOWN_SERVER_LIMIT_BUFFER); return new; } static void destroyClient(client_ds_t *client) { - closeTcpSocket(client->sock); - destroyBuffer(client->recvBuffer); - destroyBuffer(client->sendBuffer); + sock_tcp_close(client->sock); + buffer_destroy(client->recvBuffer); + buffer_destroy(client->sendBuffer); if( client->file != NULL ) { @@ -125,9 +125,9 @@ static void destroyClient(client_ds_t *client) free(client); } -int initDownServer(char *ip4, int port4) +int downServer_init(char *ip4, int port4) { - sock_server_tcp = bindTcpSocket(ip4, port4); + sock_server_tcp = sock_tcp_bind(ip4, port4); if( sock_server_tcp == NULL ) { @@ -135,18 +135,18 @@ int initDownServer(char *ip4, int port4) return -1; } - setTcpSockNonBlock(sock_server_tcp); + sock_tcp_set_non_block(sock_server_tcp); - listClient = newList(); + listClient = list_new(); return 0; } -int setDownServerSelect() +int downServer_set_select() { int i; - addSockToSelectRead(sock_server_tcp->sock); + select_add_sock_for_read(sock_server_tcp->sock); for( i = 0 ; i < listClient->count ; i++ ) { @@ -154,11 +154,11 @@ int setDownServerSelect() this = (client_ds_t *)listClient->list[i]; - addSockToSelectRead(this->sock->sock); + select_add_sock_for_read(this->sock->sock); - if( getBufferSize(this->sendBuffer) > 0 ) + if( buffer_get_size(this->sendBuffer) > 0 ) { - addSockToSelectWrite(this->sock->sock); + select_add_sock_for_write(this->sock->sock); } } @@ -170,11 +170,11 @@ static void eventNewClient(sock_tcp_t *sock_server) sock_tcp_t *sock_client; client_ds_t *client; - sock_client = getTcpNewClient(sock_server); - setTcpSockNonBlock(sock_client); + sock_client = sock_tcp_accept(sock_server); + sock_tcp_set_non_block(sock_client); client = newClient(sock_client); - addList(listClient, client); + list_add(listClient, client); } static void eventReadClient(client_ds_t * client) @@ -184,8 +184,8 @@ static void eventReadClient(client_ds_t * client) memset(buffer, 0, STR_PROTO_SIZE); - ret = readTcpSocket(client->sock, buffer, STR_PROTO_SIZE - 1); - //printf("readTcpSocket = %d\n", ret); + ret = sock_tcp_read(client->sock, buffer, STR_PROTO_SIZE - 1); + //printf("sock_tcp_read = %d\n", ret); if( ret <= 0 ) { @@ -193,13 +193,13 @@ static void eventReadClient(client_ds_t * client) return; } - if( addBuffer(client->recvBuffer, buffer, ret) < 0 ) + if( buffer_append(client->recvBuffer, buffer, ret) < 0 ) { client->status_connect = NET_STATUS_ZOMBIE; return; } - while( getBufferLine(client->recvBuffer, buffer, STR_PROTO_SIZE) >= 0 ) + while( buffer_get_line(client->recvBuffer, buffer, STR_PROTO_SIZE) >= 0 ) { int len; @@ -211,7 +211,7 @@ static void eventReadClient(client_ds_t * client) } do_proto(client, buffer); - //addBuffer(client->sendBuffer, buffer, strlen(buffer)); + //buffer_append(client->sendBuffer, buffer, strlen(buffer)); } } @@ -221,17 +221,17 @@ static void eventWriteClient(client_ds_t *client) int len; int res; - len = getBufferSize(client->sendBuffer); + len = buffer_get_size(client->sendBuffer); if( len == 0 ) { return; } - data = getBufferData(client->sendBuffer); + data = buffer_get_data(client->sendBuffer); - res = writeTcpSocket(client->sock, data, len); - //printf("writeTcpSocket = %d\n", res); + res = sock_tcp_write(client->sock, data, len); + //printf("sock_tcp_write = %d\n", res); if( res < 0 ) { @@ -239,7 +239,7 @@ static void eventWriteClient(client_ds_t *client) return; } - cutBuffer(client->sendBuffer, res); + buffer_cut(client->sendBuffer, res); } static void sendFile(client_ds_t *client) @@ -260,15 +260,15 @@ static void sendFile(client_ds_t *client) return; } - addBuffer(client->sendBuffer, buffer, count); + buffer_append(client->sendBuffer, buffer, count); client->send += count; } -int selectDownServerSocket() +int downServer_select_socket() { int i; - if( isChangeSockInSelectRead(sock_server_tcp->sock) ) + if( select_is_change_sock_for_read(sock_server_tcp->sock) ) { eventNewClient(sock_server_tcp); } @@ -279,34 +279,34 @@ int selectDownServerSocket() this = (client_ds_t *)listClient->list[i]; - if( isChangeSockInSelectRead(this->sock->sock) ) + if( select_is_change_sock_for_read(this->sock->sock) ) { eventReadClient(this); } - if( isChangeSockInSelectWrite(this->sock->sock) ) + if( select_is_change_sock_for_write(this->sock->sock) ) { eventWriteClient(this); } - if( this->file != NULL && getBufferSize(this->sendBuffer) == 0 ) + if( this->file != NULL && buffer_get_size(this->sendBuffer) == 0 ) { sendFile(this); } if( this->status_connect == NET_STATUS_ZOMBIE ) { - delListItem(listClient, i, destroyClient); + list_del_item(listClient, i, destroyClient); } } return 0; } -int quitDownServer() +int downServer_quit() { - closeTcpSocket(sock_server_tcp); - destroyListItem(listClient, destroyClient); + sock_tcp_close(sock_server_tcp); + list_destroy_item(listClient, destroyClient); return 0; } diff --git a/src/base/downServer.h b/src/base/downServer.h index 6ca8d93..6dea645 100644 --- a/src/base/downServer.h +++ b/src/base/downServer.h @@ -7,9 +7,9 @@ #include "tcp.h" #include "buffer.h" -extern int initDownServer(char *ip4, int port4); -extern int setDownServerSelect(); -extern int selectDownServerSocket(); -extern int quitDownServer(); +extern int downServer_init(char *ip4, int port4); +extern int downServer_set_select(); +extern int downServer_select_socket(); +extern int downServer_quit(); #endif diff --git a/src/base/gun.c b/src/base/gun.c index d357349..653a180 100644 --- a/src/base/gun.c +++ b/src/base/gun.c @@ -76,15 +76,15 @@ static void addShotTrivial(tux_t * tux, int x, int y, int px, int py, int gun) break; } - shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id); - addObjectToSpace(getCurrentArena()->spaceShot, shot); + shot = shot_new(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id); + space_add(arena_get_current()->spaceShot, shot); } static void addShot(tux_t * tux, int x, int y, int px, int py) { int gun; - if (getNetTypeGame() == NET_GAME_TYPE_CLIENT) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) return; if (tux->gun == GUN_BOMBBALL) @@ -125,18 +125,18 @@ static void addShot(tux_t * tux, int x, int y, int px, int py) } } -static void shotInGunSimpe(tux_t * tux) +static void gun_shotSimpe(tux_t * tux) { addShot(tux, 0, 0, +5, 0); } -static void shotInGunDualSimpe(tux_t * tux) +static void gun_shotDualSimpe(tux_t * tux) { addShot(tux, 0, -10, +6, 0); addShot(tux, 0, +10, +6, 0); } -static void shotInGunScatter(tux_t * tux) +static void gun_shotScatter(tux_t * tux) { int i; @@ -153,7 +153,7 @@ static void timer_addShotTimer(void *p) id = *((int *) p); free(p); - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux == NULL) return; @@ -167,12 +167,12 @@ static void timer_addShotTimer(void *p) tux->gun = gun; } -static void shotInGunTommy(tux_t * tux) +static void gun_shotTommy(tux_t * tux) { int i; for (i = 0; i < 10; i++) - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_addShotTimer, newInt(tux->id), i * 100); } @@ -185,7 +185,7 @@ static void timer_addLaserTimer(void *p) id = *((int *) p); free(p); - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux == NULL) return; @@ -202,12 +202,12 @@ static void timer_addLaserTimer(void *p) tux->gun = gun; } -static void shotInGunLasser(tux_t * tux) +static void gun_shotLasser(tux_t * tux) { int i; for (i = 0; i < 50; i++) - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_addLaserTimer, newInt(tux->id), i * 10); } @@ -234,32 +234,32 @@ static void putInGunMine(tux_t * tux) break; } - arena = getCurrentArena(); + arena = arena_get_current(); - if (isFreeSpace(getCurrentArena(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT)) { + if (arena__is_free_space(arena_get_current(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT)) { item_t *item; #ifndef NO_SOUND - playSound("put_mine", SOUND_GROUP_BASE); + sound_play("put_mine", SOUND_GROUP_BASE); #endif tux->shot[tux->gun]--; - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) { - item = newItem(x, y, ITEM_MINE, tux->id); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { + item = item_new(x, y, ITEM_MINE, tux->id); - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_additem_server(PROTO_SEND_ALL, NULL, item); - addObjectToSpace(arena->spaceItem, item); + space_add(arena->spaceItem, item); } } } -static void shotInGunBombball(tux_t * tux) +static void gun_shotBombball(tux_t * tux) { addShot(tux, 0, 0, +10, 0); } -void shotInGun(tux_t * tux) +void gun_shot(tux_t * tux) { if (tux->bonus != BONUS_SHOT && tux->gun != GUN_MINE) tux->shot[tux->gun]--; @@ -267,36 +267,36 @@ void shotInGun(tux_t * tux) switch (tux->gun) { case GUN_SIMPLE: #ifndef NO_SOUND - playSound("gun_revolver", SOUND_GROUP_BASE); + sound_play("gun_revolver", SOUND_GROUP_BASE); #endif - shotInGunSimpe(tux); + gun_shotSimpe(tux); break; case GUN_DUAL_SIMPLE: #ifndef NO_SOUND - playSound("gun_revolver", SOUND_GROUP_BASE); + sound_play("gun_revolver", SOUND_GROUP_BASE); #endif - shotInGunDualSimpe(tux); + gun_shotDualSimpe(tux); break; case GUN_SCATTER: #ifndef NO_SOUND - playSound("gun_scatter", SOUND_GROUP_BASE); + sound_play("gun_scatter", SOUND_GROUP_BASE); #endif - shotInGunScatter(tux); + gun_shotScatter(tux); break; case GUN_TOMMY: #ifndef NO_SOUND - playSound("gun_tommy", SOUND_GROUP_BASE); + sound_play("gun_tommy", SOUND_GROUP_BASE); #endif - shotInGunTommy(tux); + gun_shotTommy(tux); break; case GUN_LASSER: #ifndef NO_SOUND - playSound("gun_lasser", SOUND_GROUP_BASE); + sound_play("gun_lasser", SOUND_GROUP_BASE); #endif - shotInGunLasser(tux); + gun_shotLasser(tux); break; case GUN_BOMBBALL: - shotInGunBombball(tux); + gun_shotBombball(tux); break; case GUN_MINE: putInGunMine(tux); diff --git a/src/base/gun.h b/src/base/gun.h index 1f64327..46a7d29 100644 --- a/src/base/gun.h +++ b/src/base/gun.h @@ -11,5 +11,5 @@ # include "main.h" # include "tux.h" -extern void shotInGun(tux_t * p); +extern void gun_shot(tux_t * p); #endif diff --git a/src/base/homeDirector.c b/src/base/homeDirector.c index e62b7ee..f78d820 100644 --- a/src/base/homeDirector.c +++ b/src/base/homeDirector.c @@ -10,7 +10,7 @@ static char homeDirector[STR_PATH_SIZE]; -void createHomeDirector() +void homeDirector_create() { char *envHome; #ifndef __WIN32__ @@ -40,7 +40,7 @@ void createHomeDirector() } } -char *getHomeDirector() +char *homeDirector_get() { return homeDirector; } diff --git a/src/base/homeDirector.h b/src/base/homeDirector.h index 0fe1bd9..f28c7a4 100644 --- a/src/base/homeDirector.h +++ b/src/base/homeDirector.h @@ -5,6 +5,6 @@ # include "main.h" -extern void createHomeDirector(); -extern char *getHomeDirector(); +extern void homeDirector_create(); +extern char *homeDirector_get(); #endif diff --git a/src/base/idManager.c b/src/base/idManager.c index 09d3fc9..e30cd5a 100644 --- a/src/base/idManager.c +++ b/src/base/idManager.c @@ -33,16 +33,16 @@ static void destroyIdItem(id_item_t * p) free(p); } -void initListID() +void id_init_list() { - listID = newList(); + listID = list_new(); lastID = 0; DEBUG_MSG(_("Starting ID manger\n")); } -int isRegisterID(int id) +int id_is_register(int id) { int i; @@ -74,37 +74,37 @@ static int findNewID() do { //ret = ( random() % (listID->count + 8 ) ) + 1; ret = random() % MAX_ID + 1; - } while (isRegisterID(ret) != -1); + } while (id_is_register(ret) != -1); //printf("new ID %d\n", ret); return ret; } -int getNewIDcount(int count) +int id_get_newcount(int count) { int id; id = findNewID(); - addList(listID, newIdItem(id, count)); + list_add(listID, newIdItem(id, count)); return id; } -int getNewID() +int id_get_new() { - return getNewIDcount(1); + return id_get_newcount(1); } -void incID(int id) +void id_inc(int id) { id_item_t *this; int index; assert(listID != NULL); - index = isRegisterID(id); + index = id_is_register(id); if (index == -1) { assert(!_("This kind of ID was never registered!")); @@ -119,14 +119,14 @@ void incID(int id) return; } -void delID(int id) +void id_del(int id) { id_item_t *this; int index; assert(listID != NULL); - index = isRegisterID(id); + index = id_is_register(id); if (index == -1) { assert(!_("This kind of ID was never registered!")); @@ -139,14 +139,14 @@ void delID(int id) //printf("dec ID %d %d\n", this->id, this->count); if (this->count <= 0) { - delListItem(listID, index, free); + list_del_item(listID, index, free); //printf("listID->count = %d\n", listID->count); } return; } -void replaceID(int old_id, int new_id) +void id_replace(int old_id, int new_id) { int index_old_id; int index_new_id; @@ -156,10 +156,10 @@ void replaceID(int old_id, int new_id) return; } - index_old_id = isRegisterID(old_id); + index_old_id = id_is_register(old_id); assert(index_old_id != -1); - index_new_id = isRegisterID(new_id); + index_new_id = id_is_register(new_id); assert(index_new_id == -1); this = listID->list[index_old_id]; @@ -173,7 +173,7 @@ void infoID(int id) assert(listID != NULL); - index = isRegisterID(id); + index = id_is_register(id); if (index == -1) { DEBUG_MSG(_("ID %d does not exist\n"), id); @@ -188,10 +188,10 @@ void infoID(int id) return; } -void quitListID() +void id_quit_list() { DEBUG_MSG(_("Quitting ID manger\n")); assert(listID != NULL); - destroyListItem(listID, destroyIdItem); + list_destroy_item(listID, destroyIdItem); } diff --git a/src/base/idManager.h b/src/base/idManager.h index c5c2fbf..c4b6968 100644 --- a/src/base/idManager.h +++ b/src/base/idManager.h @@ -8,13 +8,13 @@ # endif # include "list.h" -extern void initListID(); -extern int isRegisterID(int id); -extern int getNewIDcount(int count); -extern int getNewID(); -extern void incID(int id); -extern void delID(int id); -extern void replaceID(int old_id, int new_id); -extern void quitListID(); +extern void id_init_list(); +extern int id_is_register(int id); +extern int id_get_newcount(int count); +extern int id_get_new(); +extern void id_inc(int id); +extern void id_del(int id); +extern void id_replace(int old_id, int new_id); +extern void id_quit_list(); #endif diff --git a/src/base/index.c b/src/base/index.c index b5da90e..fc07766 100644 --- a/src/base/index.c +++ b/src/base/index.c @@ -10,7 +10,7 @@ #define DEBUG_INDEX -static index_item_t *newIndexItem(int key, void *data) +static index_item_t *index_item_new(int key, void *data) { index_item_t *new; @@ -70,17 +70,17 @@ static void checkList(list_t * list) } #endif -static void destroyIndexItem(index_item_t * p) +static void index_item_destroy(index_item_t * p) { free(p); } -list_t *newIndex() +list_t *index_new() { - return newList(); + return list_new(); } -void addToIndex(list_t * list, int key, void *data) +void index_add(list_t * list, int key, void *data) { #ifdef DEBUG_INDEX int count = 0; @@ -91,7 +91,7 @@ void addToIndex(list_t * list, int key, void *data) int min, max, point; int len; - item = newIndexItem(key, data); + item = index_item_new(key, data); len = list->count; min = 0; @@ -111,7 +111,7 @@ void addToIndex(list_t * list, int key, void *data) #endif if (max < 0) { - insList(list, 0, item); + list_ins(list, 0, item); #ifdef DEBUG_INDEX checkList(list); #endif @@ -119,7 +119,7 @@ void addToIndex(list_t * list, int key, void *data) } if (min >= len) { - addList(list, item); + list_add(list, item); #ifdef DEBUG_INDEX checkList(list); #endif @@ -134,7 +134,7 @@ void addToIndex(list_t * list, int key, void *data) */ if (min > max) { - insList(list, point, item); + list_ins(list, point, item); #ifdef DEBUG_INDEX checkList(list); #endif @@ -195,7 +195,7 @@ static int getOffsetFromIndex(list_t * list, int key) } } -void *getFromIndex(list_t * list, int key) +void *index_get(list_t * list, int key) { int offset; @@ -211,18 +211,18 @@ void *getFromIndex(list_t * list, int key) return NULL; } -void delFromIndex(list_t * list, int key) +void index_del(list_t * list, int key) { int offset; offset = getOffsetFromIndex(list, key); if (offset != -1) { - delListItem(list, offset, destroyIndexItem); + list_del_item(list, offset, index_item_destroy); } } -void delFromIndexWithObject(list_t * list, int key, void *f) +void index_del_with_object(list_t * list, int key, void *f) { int offset; @@ -237,11 +237,11 @@ void delFromIndexWithObject(list_t * list, int key, void *f) fce = f; fce(this); - delListItem(list, offset, destroyIndexItem); + list_del_item(list, offset, index_item_destroy); } } -void actionIndexWithObject(list_t * list, void *f) +void index_action(list_t * list, void *f) { int i; @@ -256,13 +256,13 @@ void actionIndexWithObject(list_t * list, void *f) } } -void destroyIndex(list_t * list) +void index_destroy(list_t * list) { - destroyListItem(list, destroyIndexItem); + list_destroy_item(list, index_item_destroy); } -void destroyIndexWithObject(list_t * list, void *f) +void index_destroyWithObject(list_t * list, void *f) { - actionIndexWithObject(list, f); - destroyListItem(list, destroyIndexItem); + index_action(list, f); + list_destroy_item(list, index_item_destroy); } diff --git a/src/base/index.h b/src/base/index.h index 7f9cbea..9b6f2f7 100644 --- a/src/base/index.h +++ b/src/base/index.h @@ -11,13 +11,13 @@ typedef struct index_item_struct { void *data; } index_item_t; -extern list_t *newIndex(); -extern void addToIndex(list_t * list, int key, void *data); -extern void *getFromIndex(list_t * list, int key); -extern void delFromIndex(list_t * list, int key); -extern void delFromIndexWithObject(list_t * list, int key, void *f); -extern void actionIndexWithObject(list_t * list, void *f); -extern void destroyIndex(list_t * list); -extern void destroyIndexWithObject(list_t * list, void *f); +extern list_t *index_new(); +extern void index_add(list_t * list, int key, void *data); +extern void *index_get(list_t * list, int key); +extern void index_del(list_t * list, int key); +extern void index_del_with_object(list_t * list, int key, void *f); +extern void index_action(list_t * list, void *f); +extern void index_destroy(list_t * list); +extern void index_destroyWithObject(list_t * list, void *f); #endif diff --git a/src/base/item.c b/src/base/item.c index 75074bc..0ebeae2 100644 --- a/src/base/item.c +++ b/src/base/item.c @@ -38,41 +38,41 @@ static image_t *g_item[ITEM_COUNT]; static bool_t isItemInit = FALSE; -bool_t isItemInicialized() +bool_t item_is_inicialized() { return isItemInit; } -void initItem() +void item_init() { #ifndef PUBLIC_SERVER - g_item[GUN_DUAL_SIMPLE] = addImageData("item.dual.png", IMAGE_ALPHA, "item_dual_simple", IMAGE_GROUP_BASE); - g_item[GUN_TOMMY] = addImageData("item.tommy.png", IMAGE_ALPHA, "item_tommy_simple", IMAGE_GROUP_BASE); - g_item[GUN_SCATTER] = addImageData("item.scatter.png", IMAGE_ALPHA, "item_scatter_simple", IMAGE_GROUP_BASE); - g_item[GUN_LASSER] = addImageData("item.lasser.png", IMAGE_ALPHA, "item_lasser_simple", IMAGE_GROUP_BASE); - g_item[GUN_MINE] = addImageData("item.mine.png", IMAGE_ALPHA, "item_mines_simple", IMAGE_GROUP_BASE); - g_item[GUN_BOMBBALL] = addImageData("item.bombball.png", IMAGE_ALPHA, "item_bombball_simple", IMAGE_GROUP_BASE); - g_item[ITEM_MINE] = addImageData("mine.png", IMAGE_ALPHA, "item_mine_simple", IMAGE_GROUP_BASE); - g_item[ITEM_EXPLOSION] = addImageData("explosion.png", IMAGE_ALPHA, "item_explosion_simple", IMAGE_GROUP_BASE); - g_item[ITEM_BIG_EXPLOSION] = addImageData("big-explosion.png", IMAGE_ALPHA, "item_big-explosion_simple", IMAGE_GROUP_BASE); - g_item[BONUS_SPEED] = addImageData("item.bonus.speed.png", IMAGE_ALPHA, "item_bonus_speed", IMAGE_GROUP_BASE); - g_item[BONUS_SHOT] = addImageData("item.bonus.shot.png", IMAGE_ALPHA, "item_shot_speed", IMAGE_GROUP_BASE); - g_item[BONUS_TELEPORT] = addImageData("item.bonus.teleport.png", IMAGE_ALPHA, "item_teleport_speed", IMAGE_GROUP_BASE); - g_item[BONUS_GHOST] = addImageData("item.bonus.ghost.png", IMAGE_ALPHA, "item_ghost_speed", IMAGE_GROUP_BASE); - g_item[BONUS_4X] = addImageData("item.bonus.4x.png", IMAGE_ALPHA, "item_4x_speed", IMAGE_GROUP_BASE); - g_item[BONUS_HIDDEN] = addImageData("item.bonus.hidden.png", IMAGE_ALPHA, "item_hidden_speed", IMAGE_GROUP_BASE); + g_item[GUN_DUAL_SIMPLE] = image_add("item.dual.png", IMAGE_ALPHA, "item_dual_simple", IMAGE_GROUP_BASE); + g_item[GUN_TOMMY] = image_add("item.tommy.png", IMAGE_ALPHA, "item_tommy_simple", IMAGE_GROUP_BASE); + g_item[GUN_SCATTER] = image_add("item.scatter.png", IMAGE_ALPHA, "item_scatter_simple", IMAGE_GROUP_BASE); + g_item[GUN_LASSER] = image_add("item.lasser.png", IMAGE_ALPHA, "item_lasser_simple", IMAGE_GROUP_BASE); + g_item[GUN_MINE] = image_add("item.mine.png", IMAGE_ALPHA, "item_mines_simple", IMAGE_GROUP_BASE); + g_item[GUN_BOMBBALL] = image_add("item.bombball.png", IMAGE_ALPHA, "item_bombball_simple", IMAGE_GROUP_BASE); + g_item[ITEM_MINE] = image_add("mine.png", IMAGE_ALPHA, "item_mine_simple", IMAGE_GROUP_BASE); + g_item[ITEM_EXPLOSION] = image_add("explosion.png", IMAGE_ALPHA, "item_explosion_simple", IMAGE_GROUP_BASE); + g_item[ITEM_BIG_EXPLOSION] = image_add("big-explosion.png", IMAGE_ALPHA, "item_big-explosion_simple", IMAGE_GROUP_BASE); + g_item[BONUS_SPEED] = image_add("item.bonus.speed.png", IMAGE_ALPHA, "item_bonus_speed", IMAGE_GROUP_BASE); + g_item[BONUS_SHOT] = image_add("item.bonus.shot.png", IMAGE_ALPHA, "item_shot_speed", IMAGE_GROUP_BASE); + g_item[BONUS_TELEPORT] = image_add("item.bonus.teleport.png", IMAGE_ALPHA, "item_teleport_speed", IMAGE_GROUP_BASE); + g_item[BONUS_GHOST] = image_add("item.bonus.ghost.png", IMAGE_ALPHA, "item_ghost_speed", IMAGE_GROUP_BASE); + g_item[BONUS_4X] = image_add("item.bonus.4x.png", IMAGE_ALPHA, "item_4x_speed", IMAGE_GROUP_BASE); + g_item[BONUS_HIDDEN] = image_add("item.bonus.hidden.png", IMAGE_ALPHA, "item_hidden_speed", IMAGE_GROUP_BASE); #endif isItemInit = TRUE; } -item_t *newItem(int x, int y, int type, int author_id) +item_t *item_new(int x, int y, int type, int author_id) { item_t *new; new = malloc(sizeof(item_t)); assert(new != NULL); new->type = type; - new->id = getNewID(); + new->id = id_get_new(); new->x = x; new->y = y; new->frame = 0; @@ -98,14 +98,14 @@ item_t *newItem(int x, int y, int type, int author_id) break; case ITEM_EXPLOSION: #ifndef NO_SOUND - playSound("explozion", SOUND_GROUP_BASE); + sound_play("explozion", SOUND_GROUP_BASE); #endif new->w = ITEM_EXPLOSION_WIDTH; new->h = ITEM_EXPLOSION_HEIGHT; break; case ITEM_BIG_EXPLOSION: #ifndef NO_SOUND - playSound("explozion", SOUND_GROUP_BASE); + sound_play("explozion", SOUND_GROUP_BASE); #endif new->w = ITEM_BIG_EXPLOSION_WIDTH; new->h = ITEM_BIG_EXPLOSION_HEIGHT; @@ -124,7 +124,7 @@ item_t *newItem(int x, int y, int type, int author_id) return new; } -void getStatusItem(void *p, int *id, int *x, int *y, int *w, int *h) +void item_get_status(void *p, int *id, int *x, int *y, int *w, int *h) { item_t *item; @@ -136,7 +136,7 @@ void getStatusItem(void *p, int *id, int *x, int *y, int *w, int *h) *h = item->h; } -void setStatusItem(void *p, int x, int y, int w, int h) +void item_set_status(void *p, int x, int y, int w, int h) { item_t *item; @@ -147,9 +147,9 @@ void setStatusItem(void *p, int x, int y, int w, int h) item->h = h; } -void replaceItemID(item_t * item, int id) +void item_replace_id(item_t * item, int id) { - replaceID(item->id, id); + id_replace(item->id, id); item->id = id; } @@ -166,13 +166,13 @@ static int getCountWeaponOrBonusItem(space_t * spaceItem) { int count = 0; - actionSpace(spaceItem, action_countitem, &count); + space_action(spaceItem, action_countitem, &count); return count; } #endif -void addNewItem(space_t * spaceItem, int author_id) +void item_add_new_item(space_t * spaceItem, int author_id) { arena_t *arena; item_t *item; @@ -180,19 +180,19 @@ void addNewItem(space_t * spaceItem, int author_id) int type; #ifdef PUBLIC_SERVER - if (getCountWeaponOrBonusItem(spaceItem) >= atoi(getSetting("MAX_ITEM", "--max-item", "100"))) { + if (getCountWeaponOrBonusItem(spaceItem) >= atoi(publicServer_get_setting("MAX_ITEM", "--max-item", "100"))) { return; } #endif #ifndef PUBLIC_SERVER - if (isSettingAnyItem() == FALSE || getNetTypeGame() == NET_GAME_TYPE_CLIENT) { + if (setting_is_any_item() == FALSE || netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { return; } #endif - arena = getCurrentArena(); - findFreeSpace(getCurrentArena(), &new_x, &new_y, ITEM_GUN_WIDTH, ITEM_GUN_HEIGHT); + arena = arena_get_current(); + arena_find_free_space(arena_get_current(), &new_x, &new_y, ITEM_GUN_WIDTH, ITEM_GUN_HEIGHT); type = GUN_DUAL_SIMPLE; @@ -238,29 +238,29 @@ void addNewItem(space_t * spaceItem, int author_id) break; } #ifndef PUBLIC_SERVER - } while (isSettingItem(type) == FALSE || - (getNetTypeGame() == NET_GAME_TYPE_NONE && type == BONUS_HIDDEN)); + } while (setting_is_item(type) == FALSE || + (netMultiplayer_get_game_type() == NET_GAME_TYPE_NONE && type == BONUS_HIDDEN)); #endif - item = newItem(new_x, new_y, type, author_id); - addObjectToSpace(spaceItem, item); + item = item_new(new_x, new_y, type, author_id); + space_add(spaceItem, item); - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_additem_server(PROTO_SEND_ALL, NULL, item); #ifndef PUBLIC_SERVER - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) - addToRadar(item->id, new_x, new_y, RADAR_TYPE_ITEM); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) + radar_add(item->id, new_x, new_y, RADAR_TYPE_ITEM); #endif } #ifndef PUBLIC_SERVER -void drawItem(item_t * p) +void item_draw(item_t * p) { assert(p != NULL); addLayer(p->img, p->x, p->y, p->frame * p->w, 0, p->w, p->h, TUX_LAYER); } -void drawListItem(list_t * listItem) +void item_draw_list(list_t * listItem) { item_t *thisItem; int i; @@ -270,7 +270,7 @@ void drawListItem(list_t * listItem) for (i = 0; i < listItem->count; i++) { thisItem = (item_t *) listItem->list[i]; assert(thisItem != NULL); - drawItem(thisItem); + item_draw(thisItem); } } @@ -280,7 +280,7 @@ static void action_itemevent(space_t * space, item_t * item, void *p) { my_time_t currentTime; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); item->count++; if (item->count == ITEM_MAX_COUNT) { @@ -305,7 +305,7 @@ static void action_itemevent(space_t * space, item_t * item, void *p) case ITEM_EXPLOSION: case ITEM_BIG_EXPLOSION: if (item->frame == ITEM_EXPLOSION_MAX_FRAME) - delObjectFromSpaceWithObject(space, item, destroyItem); + space_del_with_item(space, item, item_destroy); break; case BONUS_SPEED: case BONUS_SHOT: @@ -319,43 +319,43 @@ static void action_itemevent(space_t * space, item_t * item, void *p) } } -void eventListItem(space_t * spaceItem) +void item_event(space_t * spaceItem) { - actionSpace(spaceItem, action_itemevent, NULL); + space_action(spaceItem, action_itemevent, NULL); } static void mineExplosion(space_t * spaceItem, item_t * item) { - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) { + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { int x, y; item_t *item_explosion; x = (item->x + item->w / 2) - ITEM_BIG_EXPLOSION_WIDTH / 2; y = (item->y + item->h / 2) - ITEM_BIG_EXPLOSION_HEIGHT / 2; - item_explosion = newItem(x, y, ITEM_BIG_EXPLOSION, item->author_id); + item_explosion = item_new(x, y, ITEM_BIG_EXPLOSION, item->author_id); - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_additem_server(PROTO_SEND_ALL, NULL, item_explosion); - addObjectToSpace(spaceItem, item_explosion); + space_add(spaceItem, item_explosion); } - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_del_server(PROTO_SEND_ALL, NULL, item->id); - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) - delObjectFromSpaceWithObject(spaceItem, item, destroyItem); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) + space_del_with_item(spaceItem, item, item_destroy); } static void action_item(space_t * space, item_t * item, int *isDel) { arena_t *arena; - arena = getCurrentArena(); + arena = arena_get_current(); switch (item->type) { case ITEM_MINE: - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) mineExplosion(space, item); break; case ITEM_EXPLOSION: @@ -369,91 +369,91 @@ static void action_shot(space_t * space, shot_t * shot, space_t * spaceItem) { int isDel = 0; - actionSpaceFromLocation(spaceItem, action_item, &isDel, + space_action_from_location(spaceItem, action_item, &isDel, shot->x, shot->y, shot->w, shot->h); if (isDel) { - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_del_server(PROTO_SEND_ALL, NULL, shot->id); - delObjectFromSpaceWithObject(space, shot, destroyShot); + space_del_with_item(space, shot, shot_destroy); } } -void eventConflictShotWithItem(arena_t * arena) +void item_event_conglicts_shot_with_item(arena_t * arena) { - if (getNetTypeGame() == NET_GAME_TYPE_CLIENT) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) return; - actionSpace(arena->spaceShot, action_shot, arena->spaceItem); + space_action(arena->spaceShot, action_shot, arena->spaceItem); } -static void eventTuxIsDeadWithItem(tux_t * tux, item_t * item) +static void tux_event_tux_is_deadWithItem(tux_t * tux, item_t * item) { if (tux->bonus == BONUS_GHOST) return; if (tux->bonus == BONUS_TELEPORT) { - tuxTeleport(tux); + tux_teleport(tux); return; } if (item->author_id == tux->id) { tux->score--; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); } if (item->author_id != tux->id) { tux_t *author; - author = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, item->author_id); + author = space_get_object_id(arena_get_current()->spaceTux, item->author_id); if (author != NULL) { author->score++; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_newtux_server(PROTO_SEND_ALL, NULL, author); } } - countRoundInc(); - eventTuxIsDead(tux); + word_inc_round(); + tux_event_tux_is_dead(tux); } static void tuxGiveBonus(tux_t * tux, item_t * item) { #ifndef NO_SOUND - playSound("item_bonus", SOUND_GROUP_BASE); + sound_play("item_bonus", SOUND_GROUP_BASE); #endif tux->bonus = item->type; tux->bonus_time = TUX_MAX_BONUS; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); #ifndef PUBLIC_SERVER - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) - delFromRadar(item->id); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) + radar_del(item->id); #endif } static void tuxGiveGun(tux_t * tux, item_t * item) { #ifndef NO_SOUND - playSound("item_gun", SOUND_GROUP_BASE); + sound_play("item_gun", SOUND_GROUP_BASE); #endif tux->pickup_time = 0; tux->shot[item->type] += GUN_MAX_SHOT; tux->gun = item->type; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); #ifndef PUBLIC_SERVER - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) - delFromRadar(item->id); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) + radar_del(item->id); #endif } @@ -468,12 +468,12 @@ static void action_giveitem(space_t * space, item_t * item, tux_t * tux) case GUN_BOMBBALL: tuxGiveGun(tux, item); - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_del_server(PROTO_SEND_ALL, NULL, item->id); - delObjectFromSpaceWithObject(space, item, destroyItem); + space_del_with_item(space, item, item_destroy); #ifdef PUBLIC_SERVER - addNewItem(space, ID_UNKNOWN); + item_add_new_item(space, ID_UNKNOWN); #endif break; @@ -484,7 +484,7 @@ static void action_giveitem(space_t * space, item_t * item, tux_t * tux) case ITEM_EXPLOSION: case ITEM_BIG_EXPLOSION: if (tux->bonus != BONUS_GHOST) - eventTuxIsDeadWithItem(tux, item); + tux_event_tux_is_deadWithItem(tux, item); break; case BONUS_SPEED: case BONUS_SHOT: @@ -494,42 +494,42 @@ static void action_giveitem(space_t * space, item_t * item, tux_t * tux) case BONUS_HIDDEN: tuxGiveBonus(tux, item); - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) proto_send_del_server(PROTO_SEND_ALL, NULL, item->id); - delObjectFromSpaceWithObject(space, item, destroyItem); + space_del_with_item(space, item, item_destroy); #ifdef PUBLIC_SERVER - addNewItem(space, ID_UNKNOWN); + item_add_new_item(space, ID_UNKNOWN); #endif break; } } -void eventGiveTuxListItem(tux_t * tux, space_t * spaceItem) +void item_tux_give_list_item(tux_t * tux, space_t * spaceItem) { int x, y, w, h; assert(spaceItem != NULL); assert(tux != NULL); - if (getNetTypeGame() == NET_GAME_TYPE_CLIENT) + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) return; if (tux->status == TUX_STATUS_DEAD) return; - getTuxProportion(tux, &x, &y, &w, &h); - actionSpaceFromLocation(spaceItem, action_giveitem, tux, x, y, w, h); + tux_get_proportion(tux, &x, &y, &w, &h); + space_action_from_location(spaceItem, action_giveitem, tux, x, y, w, h); } -void destroyItem(item_t * p) +void item_destroy(item_t * p) { assert(p != NULL); - delID(p->id); + id_del(p->id); free(p); } -void quitItem() +void item_quiy() { isItemInit = FALSE; } diff --git a/src/base/item.h b/src/base/item.h index 5782ffa..f471bad 100644 --- a/src/base/item.h +++ b/src/base/item.h @@ -48,21 +48,21 @@ typedef struct item_struct { # endif } item_t; -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); +extern bool_t item_is_inicialized(); +extern void item_init(); +extern item_t *item_new(int x, int y, int type, int author_id); +extern void item_get_status(void *p, int *id, int *x, int *y, int *w, int *h); +extern void item_set_status(void *p, int x, int y, int w, int h); +extern void item_replace_id(item_t * item, int id); +extern void item_add_new_item(space_t * spaceItem, int author_id); # ifndef PUBLIC_SERVER -extern void drawItem(item_t * p); -extern void drawListItem(list_t * listItem); +extern void item_draw(item_t * p); +extern void item_draw_list(list_t * listItem); # endif -extern void eventListItem(space_t * listSpace); -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(); +extern void item_event(space_t * listSpace); +extern void item_event_conglicts_shot_with_item(arena_t * arena); +extern void item_event_tux_give_item(tux_t * tux, item_t * item, space_t * spaceItem); +extern void item_tux_give_list_item(tux_t * tux, space_t * spaceItem); +extern void item_destroy(item_t * p); +extern void item_quiy(); #endif diff --git a/src/base/list.c b/src/base/list.c index dc22a0b..d211bec 100644 --- a/src/base/list.c +++ b/src/base/list.c @@ -7,7 +7,7 @@ #include "main.h" #include "list.h" -list_t *newList() +list_t *list_new() { list_t *new; @@ -17,7 +17,7 @@ list_t *newList() return new; } -list_t *cloneList(list_t * p) +list_t *list_clone(list_t * p) { list_t *new; @@ -32,7 +32,7 @@ list_t *cloneList(list_t * p) return new; } -list_t *cloneListItem(list_t * p, void *f) +list_t *list_clone_item(list_t * p, void *f) { list_t *new; void *(*fce) (void *); @@ -40,7 +40,7 @@ list_t *cloneListItem(list_t * p, void *f) assert(p != NULL); assert(f != NULL); - new = cloneList(p); + new = list_clone(p); fce = f; for (i = 0; i < p->count; i++) @@ -49,7 +49,7 @@ list_t *cloneListItem(list_t * p, void *f) return new; } -void addList(list_t * p, void *item) +void list_add(list_t * p, void *item) { assert(p != NULL); @@ -84,23 +84,23 @@ void addList(list_t * p, void *item) } } -void insList(list_t * p, int n, void *item) +void list_ins(list_t * p, int n, void *item) { assert(p != NULL); - addList(p, NULL); // :) + list_add(p, NULL); // :) assert(n >= 0 || n < p->count); memmove(p->list + n + 1, p->list + n, ((p->count - 1) - n) * sizeof(void *)); p->list[n] = item; } -void *getList(list_t * p, int n) +void *list_get(list_t * p, int n) { assert(p != NULL); assert(n >= 0 || n < p->count); return p->list[n]; } -int searchListItem(list_t * p, void *n) +int list_search(list_t * p, void *n) { int i; @@ -113,7 +113,7 @@ int searchListItem(list_t * p, void *n) return -1; } -void delList(list_t * p, int n) +void list_del(list_t * p, int n) { assert(p != NULL); assert(n >= 0 || n < p->count); @@ -136,7 +136,7 @@ void delList(list_t * p, int n) } } -void delListItem(list_t * p, int n, void *f) +void list_del_item(list_t * p, int n, void *f) { int (*fce) (void *); @@ -147,15 +147,15 @@ void delListItem(list_t * p, int n, void *f) if (fce != NULL) fce(p->list[n]); - delList(p, n); + list_del(p, n); } -void listDoEmpty(list_t * p) +void list_do_empty(list_t * p) { p->count = 0; } -void destroyList(list_t * p) +void list_destroy(list_t * p) { assert(p != NULL); @@ -165,7 +165,7 @@ void destroyList(list_t * p) free(p); } -void destroyListItem(list_t * p, void *f) +void list_destroy_item(list_t * p, void *f) { void (*fce) (void *); int i; @@ -178,5 +178,5 @@ void destroyListItem(list_t * p, void *f) for (i = 0; i < p->count; i++) fce(p->list[i]); - destroyList(p); + list_destroy(p); } diff --git a/src/base/list.h b/src/base/list.h index f63628e..337f1cd 100644 --- a/src/base/list.h +++ b/src/base/list.h @@ -11,16 +11,16 @@ typedef struct list_str { 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); +extern list_t *list_new(); +extern list_t *list_clone(list_t * p); +extern list_t *list_clone_item(list_t * p, void *f); +extern void list_add(list_t * p, void *item); +extern void list_ins(list_t * p, int n, void *item); +extern void *list_get(list_t * p, int n); +extern int list_search(list_t * p, void *n); +extern void list_del(list_t * p, int n); +extern void list_del_item(list_t * p, int n, void *f); +extern void list_do_empty(list_t * p); +extern void list_destroy(list_t * p); +extern void list_destroy_item(list_t * p, void *f); #endif diff --git a/src/base/main.c b/src/base/main.c index fe8ac31..b208f2e 100644 --- a/src/base/main.c +++ b/src/base/main.c @@ -166,11 +166,11 @@ int main(int argc, char *argv[]) #endif #ifndef PUBLIC_SERVER - startGame(); + game_start(); #endif #ifdef PUBLIC_SERVER - startPublicServer(); + publicServer_start(); #endif return 0; diff --git a/src/base/modules.c b/src/base/modules.c index 75f581e..9f2afae 100644 --- a/src/base/modules.c +++ b/src/base/modules.c @@ -27,32 +27,32 @@ static export_fce_t export_fce = { #ifndef PUBLIC_SERVER .fce_addLayer = addLayer, - .fce_getImage = getImage, + .fce_image_get = image_get, #endif - .fce_loadDepModule = loadDepModule, - .fce_addToShareFce = addToShareFce, - .fce_getShareFce = getShareFce, + .fce_module_load_dep = module_load_dep, + .fce_shareFunction_add = shareFunction_add, + .fce_shareFunction_get = shareFunction_get, - .fce_getValue = getArenaValue, - .fce_getNetTypeGame = getNetTypeGame, - .fce_getTuxProportion = getTuxProportion, - .fce_setTuxProportion = setTuxProportion, - .fce_actionTux = actionTux, + .fce_getValue = arenaFile_get_value, + .fce_netMultiplayer_get_game_type = netMultiplayer_get_game_type, + .fce_tux_get_proportion = tux_get_proportion, + .fce_tux_set_proportion = tux_set_proportion, + .fce_tux_action = tux_action, - .fce_getMyTime = getMyTime, + .fce_timer_get_current_time = timer_get_current_time, - .fce_getCurrentArena = getCurrentArena, - .fce_conflictSpace = conflictSpace, - .fce_isFreeSpace = isFreeSpace, - .fce_findFreeSpace = findFreeSpace, + .fce_arena_get_current = arena_get_current, + .fce_arena_conflict_space = arena_conflict_space, + .fce_arena__is_free_space = arena__is_free_space, + .fce_arena_find_free_space = arena_find_free_space, .fce_proto_send_module_server = proto_send_module_server, #ifndef PUBLIC_SERVER .fce_proto_send_module_client = proto_send_module_client, #endif - .fce_destroyShot = destroyShot, - .fce_boundBombBall = boundBombBall, - .fce_transformOnlyLasser = transformOnlyLasser + .fce_shot_destroy = shot_destroy, + .fce_shot_bound_bombBall = shot_bound_bombBall, + .fce_shot_transform_lasser = shot_transform_lasser }; static list_t *listModule; @@ -186,10 +186,10 @@ static int destroyModule(module_t * p) return 0; } -void initModule() +void module_init() { - listModule = newList(); - initShareFunction(); + listModule = list_new(); + shareFunction_init(); } int isModuleLoaded(char *name) @@ -207,7 +207,7 @@ int isModuleLoaded(char *name) return 0; } -int loadModule(char *name) +int module_load(char *name) { module_t *module; @@ -223,19 +223,19 @@ int loadModule(char *name) return -1; } - addList(listModule, module); + list_add(listModule, module); return 0; } -int loadDepModule(char *name) +int module_load_dep(char *name) { if (isModuleLoaded(name)) return 0; - return loadModule(name); + return module_load(name); } -void cmdModule(char *s) +void module_cmd(char *s) { int i; @@ -248,7 +248,7 @@ void cmdModule(char *s) } #ifndef PUBLIC_SERVER -void drawModule(int x, int y, int w, int h) +void module_draw(int x, int y, int w, int h) { int i; @@ -261,7 +261,7 @@ void drawModule(int x, int y, int w, int h) } #endif -void eventModule() +void module_event() { int i; @@ -273,7 +273,7 @@ void eventModule() } } -int isConflictModule(int x, int y, int w, int h) +int module_is_conflict(int x, int y, int w, int h) { int i; @@ -288,7 +288,7 @@ int isConflictModule(int x, int y, int w, int h) return 0; } -int recvMsgModule(char *msg) +int module_recv_msg(char *msg) { int i; @@ -301,8 +301,8 @@ int recvMsgModule(char *msg) return 0; } -void quitModule() +void module_quit() { - destroyListItem(listModule, destroyModule); - quitShareFunction(); + list_destroy_item(listModule, destroyModule); + shareFunction_quit(); } diff --git a/src/base/modules.h b/src/base/modules.h index a22c972..95d6e98 100644 --- a/src/base/modules.h +++ b/src/base/modules.h @@ -21,37 +21,37 @@ typedef struct export_fce_s { int (*fce_getValue) (char *line, char *env, char *val, int len); # ifndef PUBLIC_SERVER - image_t *(*fce_getImage) (char *group, char *name); + image_t *(*fce_image_get) (char *group, char *name); void (*fce_addLayer) (image_t * img, int x, int y, int px, int py, int w, int h, int player); # endif - int (*fce_getNetTypeGame) (); - int (*fce_loadDepModule) (char *name); - void (*fce_addToShareFce) (char *name, void *function); - void *(*fce_getShareFce) (char *name); + int (*fce_netMultiplayer_get_game_type) (); + int (*fce_module_load_dep) (char *name); + void (*fce_shareFunction_add) (char *name, void *function); + void *(*fce_shareFunction_get) (char *name); - void (*fce_getTuxProportion) (tux_t * tux, int *x, int *y, int *w, int *h); - void (*fce_setTuxProportion) (tux_t * tux, int x, int y); + void (*fce_tux_get_proportion) (tux_t * tux, int *x, int *y, int *w, int *h); + void (*fce_tux_set_proportion) (tux_t * tux, int x, int y); tux_t *(*fce_getTuxID) (list_t * listTux, int id); - void (*fce_actionTux) (tux_t * tux, int action); + void (*fce_tux_action) (tux_t * tux, int action); - arena_t *(*fce_getCurrentArena) (); - int (*fce_conflictSpace) (int x1, int y1, int w1, int h1, int x2, int y2, + arena_t *(*fce_arena_get_current) (); + int (*fce_arena_conflict_space) (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); + int (*fce_arena__is_free_space) (arena_t * arena, int x, int y, int w, int h); + void (*fce_arena_find_free_space) (arena_t * arena, int *x, int *y, int w, int h); void (*fce_proto_send_module_server) (int type, client_t * client, char *msg); void (*fce_proto_send_module_client) (char *msg); - my_time_t(*fce_getMyTime) (); + my_time_t(*fce_timer_get_current_time) (); - void (*fce_destroyShot) (shot_t * p); - void (*fce_boundBombBall) (shot_t * shot); - void (*fce_transformOnlyLasser) (shot_t * shot); + void (*fce_shot_destroy) (shot_t * p); + void (*fce_shot_bound_bombBall) (shot_t * shot); + void (*fce_shot_transform_lasser) (shot_t * shot); } export_fce_t; typedef struct module_s { @@ -74,16 +74,16 @@ typedef struct module_s { } module_t; -extern void initModule(); -extern int loadModule(char *name); -extern int loadDepModule(char *name); +extern void module_init(); +extern int module_load(char *name); +extern int module_load_dep(char *name); # ifndef PUBLIC_SERVER -extern void drawModule(int x, int y, int w, int h); +extern void module_draw(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 int recvMsgModule(char *msg); -extern void quitModule(); +extern void module_event(); +extern void module_cmd(char *s); +extern int module_is_conflict(int x, int y, int w, int h); +extern int module_recv_msg(char *msg); +extern void module_quit(); #endif diff --git a/src/base/myTimer.c b/src/base/myTimer.c index 6e4a54f..0f72d3e 100644 --- a/src/base/myTimer.c +++ b/src/base/myTimer.c @@ -18,24 +18,24 @@ static struct timeval my_start = {.tv_sec = 0,.tv_usec = 0 }; -list_t *newTimer() +list_t *timer_new() { - return newList(); + return list_new(); } -void restartTimer() +void timer_restart() { gettimeofday(&my_start, NULL); } -my_time_t getMyTime() +my_time_t timer_get_current_time() { struct timeval now; my_time_t ticks; if (my_start.tv_sec == 0 && my_start.tv_usec == 0) - restartTimer(); + timer_restart(); gettimeofday(&now, NULL); ticks = (now.tv_sec - my_start.tv_sec) * 1000 + (now.tv_usec - my_start.tv_usec) / 1000; @@ -44,7 +44,7 @@ my_time_t getMyTime() return ticks; } -my_time_t getMyTimeMicro() +my_time_t timer_get_current_timeMicro() { static struct timeval my_micro_start = {.tv_sec = 0,.tv_usec = 0 }; struct timeval now; @@ -60,7 +60,7 @@ my_time_t getMyTimeMicro() return ticks; } -my_timer_t *newTimerItem(int type, void (*fce) (void *p), void *arg, +my_timer_t *timer_newItem(int type, void (*fce) (void *p), void *arg, my_time_t my_time) { static int new_id = 0; @@ -74,35 +74,35 @@ my_timer_t *newTimerItem(int type, void (*fce) (void *p), void *arg, new->type = type; new->fce = fce; new->arg = arg; - new->createTime = getMyTime(); + new->createTime = timer_get_current_time(); new->time = my_time; return new; } -static void destroyTimerItem(my_timer_t * p) +static void timer_destroyItem(my_timer_t * p) { assert(p != NULL); free(p); } -int addTaskToTimer(list_t * listTimer, int type, void (*fce) (void *p), void *arg, my_time_t my_time) +int timer_add_task(list_t * listTimer, int type, void (*fce) (void *p), void *arg, my_time_t my_time) { my_timer_t *new; - new = newTimerItem(type, fce, arg, my_time); - addList(listTimer, new); + new = timer_newItem(type, fce, arg, my_time); + list_add(listTimer, new); return new->id; } -void eventTimer(list_t * listTimer) +void timer_event(list_t * listTimer) { int i; my_timer_t *thisTimer; my_time_t currentTime; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); for (i = 0; i < listTimer->count; i++) { thisTimer = (my_timer_t *) listTimer->list[i]; @@ -112,14 +112,14 @@ void eventTimer(list_t * listTimer) case TIMER_ONE: if (currentTime >= thisTimer->createTime + thisTimer->time) { thisTimer->fce(thisTimer->arg); - delListItem(listTimer, i, free); + list_del_item(listTimer, i, free); i--; } break; case TIMER_PERIODIC: if (currentTime >= thisTimer->createTime + thisTimer->time) { thisTimer->fce(thisTimer->arg); - thisTimer->createTime = getMyTime(); + thisTimer->createTime = timer_get_current_time(); } break; default: @@ -129,7 +129,7 @@ void eventTimer(list_t * listTimer) } } -void delTimer(list_t * listTimer, int id) +void timer_del(list_t * listTimer, int id) { my_timer_t *thisTimer; int i; @@ -140,7 +140,7 @@ void delTimer(list_t * listTimer, int id) assert(thisTimer != NULL); if (thisTimer->id == (unsigned)id) { - delListItem(listTimer, i, free); + list_del_item(listTimer, i, free); return; } } @@ -148,7 +148,7 @@ void delTimer(list_t * listTimer, int id) } -void destroyTimer(list_t * listTimer) +void timer_destroy(list_t * listTimer) { - destroyListItem(listTimer, destroyTimerItem); + list_destroy_item(listTimer, timer_destroyItem); } diff --git a/src/base/myTimer.h b/src/base/myTimer.h index 66a5e67..7fc9d03 100644 --- a/src/base/myTimer.h +++ b/src/base/myTimer.h @@ -17,12 +17,12 @@ typedef struct my_timer_struct { 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), +extern list_t *timer_new(); +extern void timer_restart(); +extern my_time_t timer_get_current_time(); +extern int timer_add_task(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); +extern void timer_event(list_t * listTimer); +extern void timer_del(list_t * listTimer, int id); +extern void timer_destroy(list_t * listTimer); #endif diff --git a/src/base/net_multiplayer.c b/src/base/net_multiplayer.c index d21f81d..62f298b 100644 --- a/src/base/net_multiplayer.c +++ b/src/base/net_multiplayer.c @@ -24,16 +24,16 @@ static int netGameType; -int getNetTypeGame() +int netMultiplayer_get_game_type() { return netGameType; } -int initNetMuliplayerForGameServer(char *ip4, int port4, char *ip6, int port6) +int netMultiplayer_init_for_game_server(char *ip4, int port4, char *ip6, int port6) { int ret; - ret = initServer(ip4, port4, ip6, port6); + ret = server_init(ip4, port4, ip6, port6); if (ret > 0) { netGameType = NET_GAME_TYPE_SERVER; @@ -42,7 +42,7 @@ int initNetMuliplayerForGameServer(char *ip4, int port4, char *ip6, int port6) return ret; } -int initNetMuliplayer(int type, char *ip, int port, int proto) +int netMultiplayer_init(int type, char *ip, int port, int proto) { netGameType = type; @@ -53,14 +53,14 @@ int initNetMuliplayer(int type, char *ip, int port, int proto) case NET_GAME_TYPE_SERVER: switch (proto) { case PROTO_UDPv4: - if (initServer(ip, port, NULL, 0) != 1) { + if (server_init(ip, port, NULL, 0) != 1) { fprintf(stderr, _("Unable to inicialize network game as server!\n")); netGameType = NET_GAME_TYPE_NONE; return -1; } break; case PROTO_UDPv6: - if (initServer(NULL, 0, ip, port) != 1) { + if (server_init(NULL, 0, ip, port) != 1) { fprintf(stderr, _("Unable to inicialize network game as server!\n")); netGameType = NET_GAME_TYPE_NONE; return -1; @@ -71,7 +71,7 @@ int initNetMuliplayer(int type, char *ip, int port, int proto) #ifndef PUBLIC_SERVER case NET_GAME_TYPE_CLIENT: - if (initClient(ip, port) != 0) { + if (client_init(ip, port) != 0) { fprintf(stderr, _("Unable to inicialize network game as client!\n")); netGameType = NET_GAME_TYPE_NONE; return -1; @@ -86,19 +86,19 @@ int initNetMuliplayer(int type, char *ip, int port, int proto) return 0; } -void eventNetMultiplayer() +void netMultiplayer_event() { switch (netGameType) { case NET_GAME_TYPE_NONE: break; case NET_GAME_TYPE_SERVER: - eventServer(); + server_event(); break; #ifndef PUBLIC_SERVER case NET_GAME_TYPE_CLIENT: - eventClient(); + client_event(); break; #endif default: @@ -107,19 +107,19 @@ void eventNetMultiplayer() } } -void quitNetMultiplayer() +void netMultiplayer_quit() { switch (netGameType) { case NET_GAME_TYPE_NONE: break; case NET_GAME_TYPE_SERVER: - quitServer(); + server_quit(); break; #ifndef PUBLIC_SERVER case NET_GAME_TYPE_CLIENT: - quitClient(); + client_quit(); break; #endif default: diff --git a/src/base/net_multiplayer.h b/src/base/net_multiplayer.h index 0d47e5d..c11a168 100644 --- a/src/base/net_multiplayer.h +++ b/src/base/net_multiplayer.h @@ -28,12 +28,12 @@ # define NET_MASTER_PORT 6800 # ifdef PUBLIC_SERVER -extern int initNetMuliplayerForGameServer(char *ip4, int port4, char *ip6, int port6); +extern int netMultiplayer_init_for_game_server(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(); +extern int netMultiplayer_init(int type, char *ip, int port, int proto); +extern int netMultiplayer_get_game_type(); +extern void netMultiplayer_event(); +extern void netMultiplayer_quit(); #endif diff --git a/src/base/protect.c b/src/base/protect.c index d73b7dc..a384734 100644 --- a/src/base/protect.c +++ b/src/base/protect.c @@ -13,8 +13,8 @@ protect_t *newProtect() protect_t *new; new = malloc(sizeof(protect_t)); - new->lastMove = getMyTime(); - new->lastPing = getMyTime(); + new->lastMove = timer_get_current_time(); + new->lastPing = timer_get_current_time(); new->avarage = 0; new->count = 0; new->isDown = FALSE; @@ -27,10 +27,10 @@ void refreshLastMove(protect_t * p) my_time_t currentTime; my_time_t interval; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); interval = currentTime - p->lastMove; - p->lastMove = getMyTime(); + p->lastMove = timer_get_current_time(); p->avarage += interval; p->count++; @@ -53,9 +53,9 @@ void rereshLastPing(protect_t * p) { //my_time_t currentTime; //my_time_t interval; - //currentTime = getMyTime(); + //currentTime = timer_get_current_time(); //interval = currentTime - p->lastPing; - p->lastPing = getMyTime(); + p->lastPing = timer_get_current_time(); //printf("interval = %d\n", interval); } @@ -64,7 +64,7 @@ bool_t isDown(protect_t * p) my_time_t currentTime; my_time_t interval; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); interval = currentTime - p->lastPing; if (interval > PROTECT_PING_INTERVAL_TIMEOUT) diff --git a/src/base/proto.c b/src/base/proto.c index 69dd1a8..be54593 100644 --- a/src/base/proto.c +++ b/src/base/proto.c @@ -44,7 +44,7 @@ void proto_send_error_server(int type, client_t * client, int errorcode) snprintf(msg, STR_PROTO_SIZE, "error %d\n", errorcode); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } #ifndef PUBLIC_SERVER @@ -67,16 +67,16 @@ void proto_recv_error_client(char *msg) switch (errorcode) { case PROTO_ERROR_CODE_BAD_VERSION: - setMsgToAnalyze(_("Version of your client isn't supported by the server.")); - setWorldEnd(); + analyze_set_msg(_("Version of your client isn't supported by the server.")); + word_do_end(); break; case PROTO_ERROR_CODE_TIMEOUT: - setMsgToAnalyze(_("The timeout of ping from server is out")); - setWorldEnd(); + analyze_set_msg(_("The timeout of ping from server is out")); + word_do_end(); break; case PROTO_ERROR_LIMIT_MAX_CLIENT: - setMsgToAnalyze(_("The maximum amount of connected players has been exceeded!")); - setWorldEnd(); + analyze_set_msg(_("The maximum amount of connected players has been exceeded!")); + word_do_end(); break; } } @@ -93,7 +93,7 @@ void proto_send_hello_client(char *name) getParamElse("--version", TUXANCI_VERSION), name); printf("-> %s", msg); - sendServer(msg); + client_send(msg); } #endif @@ -112,12 +112,12 @@ static void sendInfoCreateClient(client_t * client) assert(client != NULL); - listClient = getListServerClient(); + listClient = server_get_list_clients(); proto_send_init_server(PROTO_SEND_ONE, client, client); #ifndef PUBLIC_SERVER - proto_send_newtux_server(PROTO_SEND_ONE, client, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT)); + proto_send_newtux_server(PROTO_SEND_ONE, client, word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT)); #endif for (i = 0; i < listClient->count; i++) { @@ -135,11 +135,11 @@ static void sendInfoCreateClient(client_t * client) } } - actionSpace(getCurrentArena()->spaceItem, action_sendItem, client); + space_action(arena_get_current()->spaceItem, action_sendItem, client); /* - for( i = 0 ; i < getCurrentArena()->spaceItem->listIndex->count; i++) + for( i = 0 ; i < arena_get_current()->spaceItem->listIndex->count; i++) { - thisItem = (item_t *) getCurrentArena()->spaceItem->list->list[i]; + thisItem = (item_t *) arena_get_current()->spaceItem->list->list[i]; proto_send_additem_server(PROTO_SEND_ONE, client, thisItem); } */ @@ -155,9 +155,9 @@ void proto_recv_hello_server(client_t * client, char *msg) assert(client != NULL); - if (getSpaceCount(getCurrentArena()->spaceTux) + 1 > getServerMaxClients()) { + if (space_get_count(arena_get_current()->spaceTux) + 1 > server_get_max_clients()) { proto_send_error_server(PROTO_SEND_ONE, client, PROTO_ERROR_LIMIT_MAX_CLIENT); - eventMsgInCheckFront(client); + checkFront_event(client); client->status = NET_STATUS_ZOMBIE; return; } @@ -167,7 +167,7 @@ void proto_recv_hello_server(client_t * client, char *msg) #ifdef PUBLIC_SERVER if (supportVersion == NULL) { - supportVersion = getSetting("SUPPORT_CLIENTS", "--support-clients", TUXANCI_VERSION); + supportVersion = publicServer_get_setting("SUPPORT_CLIENTS", "--support-clients", TUXANCI_VERSION); } #endif @@ -185,22 +185,22 @@ void proto_recv_hello_server(client_t * client, char *msg) if (strstr(supportVersion, version) == NULL) { proto_send_error_server(PROTO_SEND_ONE, client, PROTO_ERROR_CODE_BAD_VERSION); - eventMsgInCheckFront(client); + checkFront_event(client); client->status = NET_STATUS_ZOMBIE; return; } - client->tux = newTux(); + client->tux = tux_new(); client->tux->control = TUX_CONTROL_NET; client->tux->client = client; - addObjectToSpace(getCurrentArena()->spaceTux, client->tux); + space_add(arena_get_current()->spaceTux, client->tux); if (strlen(name) > STR_NAME_SIZE - 1) { name[STR_NAME_SIZE - 1] = '\0'; } - tuxSetName(client->tux, name); + tux_set_name(client->tux, name); sendInfoCreateClient(client); } @@ -219,14 +219,14 @@ void proto_send_status_server(int type, client_t * client) #endif #ifdef PUBLIC_SERVER - name = getSetting("NAME", "--name", "noname"); + name = publicServer_get_setting("NAME", "--name", "noname"); #endif version = TUXANCI_VERSION; - clients = getCurrentArena()->spaceTux->listIndex->count; - maxclients = getServerMaxClients(); - uptime = (unsigned int) getUpdateServer(); - arena = getArenaNetName(getChoiceArena()); + clients = arena_get_current()->spaceTux->listIndex->count; + maxclients = server_get_max_clients(); + uptime = (unsigned int) server_get_update(); + arena = arenaFile_get_net_name(choiceArena_get()); snprintf(msg, STR_PROTO_SIZE, "name: %s\n" @@ -236,7 +236,7 @@ void proto_send_status_server(int type, client_t * client) "uptime: %d\n" "arena: %s\n", name, version, clients, maxclients, uptime, arena); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); //proto_send(type, client, msg); } @@ -257,7 +257,7 @@ void proto_send_listscore_server(int type, client_t * client, int max) strcpy(msg, ""); for (i = 0; i < max; i++) { - str = getTableItem(i); + str = highScore_get_table(i); if (str == NULL) { break; @@ -268,7 +268,7 @@ void proto_send_listscore_server(int type, client_t * client, int max) } //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); free(msg); } @@ -298,7 +298,7 @@ void proto_send_check_client(int id) char msg[STR_PROTO_SIZE]; snprintf(msg, STR_PROTO_SIZE, "check %d\n", id); - sendServer(msg); + client_send(msg); } #endif @@ -317,7 +317,7 @@ void proto_recv_check_server(client_t * client, char *msg) return; } - delMsgInCheckFront(client->listSendMsg, id); + checkFront_del_msg(client->listSendMsg, id); } void proto_send_init_server(int type, client_t * client, client_t * client2) @@ -331,17 +331,17 @@ void proto_send_init_server(int type, client_t * client, client_t * client2) count = WORLD_COUNT_ROUND_UNLIMITED; #ifndef PUBLIC_SERVER - getSettingCountRound(&count); + publicServer_get_settingCountRound(&count); #endif - check_id = getNewIDcount(0); + check_id = id_get_newcount(0); snprintf(msg, STR_PROTO_SIZE, "init %d %d %d %d %s %d\n", client2->tux->id, client2->tux->x, client2->tux->y, - count, getArenaNetName(getChoiceArena()), check_id); + count, arenaFile_get_net_name(choiceArena_get()), check_id); //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_CHECK, check_id); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_CHECK, check_id); } #ifndef PUBLIC_SERVER @@ -368,25 +368,25 @@ void proto_recv_init_client(char *msg) proto_send_check_client(check_id); - if (getCurrentArena() != NULL) { + if (arena_get_current() != NULL) { return; } - setWorldArena(getArenaFileFormNetName(arena_name)); + word_set_arena(arenaFile_get_file_format_net_name(arena_name)); - arena = getCurrentArena(); + arena = arena_get_current(); arena->max_countRound = n; - tux = newTux(); - replaceTuxID(tux, id); + tux = tux_new(); + tux_replace_id(tux, id); tux->x = x; tux->y = y; tux->control = TUX_CONTROL_KEYBOARD_RIGHT; - setControlTux(tux, TUX_CONTROL_KEYBOARD_RIGHT); + word_set_control_tux(tux, TUX_CONTROL_KEYBOARD_RIGHT); - getSettingNameRight(tux->name); + publicServer_get_settingNameRight(tux->name); - addObjectToSpace(arena->spaceTux, tux); + space_add(arena->spaceTux, tux); } #endif @@ -399,7 +399,7 @@ proto_send_event_server(int type, client_t * client, tux_t * tux, int action) snprintf(msg, STR_PROTO_SIZE, "event %d %d\n", tux->id, action); //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } #ifndef PUBLIC_SERVER @@ -419,11 +419,11 @@ void proto_recv_event_client(char *msg) return; } - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux != NULL) { - actionTux(tux, action); - addToRadar(tux->id, tux->x, tux->y, RADAR_TYPE_TUX); + tux_action(tux, action); + radar_add(tux->id, tux->x, tux->y, RADAR_TYPE_TUX); } } @@ -437,7 +437,7 @@ void proto_send_event_client(int action) snprintf(msg, STR_PROTO_SIZE, "event %d\n", action); - sendServer(msg); + client_send(msg); } #endif @@ -465,7 +465,7 @@ void proto_recv_event_server(client_t * client, char *msg) refreshLastMove(client->protect); - actionTux(client->tux, action); + tux_action(client->tux, action); } void proto_send_newtux_server(int type, client_t * client, tux_t * tux) @@ -479,7 +479,7 @@ void proto_send_newtux_server(int type, client_t * client, tux_t * tux) x = TUX_LOCATE_UNKNOWN; y = TUX_LOCATE_UNKNOWN; } else { - getTuxProportion(tux, &x, &y, NULL, NULL); + tux_get_proportion(tux, &x, &y, NULL, NULL); } snprintf(msg, STR_PROTO_SIZE, "newtux %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d\n", @@ -491,7 +491,7 @@ void proto_send_newtux_server(int type, client_t * client, tux_t * tux) tux->shot[GUN_BOMBBALL], tux->bonus_time, tux->pickup_time); //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } @@ -510,7 +510,7 @@ void proto_recv_newtux_client(char *msg) assert(msg != NULL); - if (getCurrentArena() == NULL) { + if (arena_get_current() == NULL) { return; } @@ -524,31 +524,31 @@ void proto_recv_newtux_client(char *msg) return; } - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux != NULL) { assert(tux->id == id); } if (tux == NULL) { - tux = newTux(); - replaceTuxID(tux, id); + tux = tux_new(); + tux_replace_id(tux, id); tux->control = TUX_CONTROL_NET; - addObjectToSpace(getCurrentArena()->spaceTux, tux); + space_add(arena_get_current()->spaceTux, tux); } if (tux->control == TUX_CONTROL_KEYBOARD_RIGHT && x == TUX_LOCATE_UNKNOWN && y == TUX_LOCATE_UNKNOWN) { - getTuxProportion(tux, &x, &y, NULL, NULL); + tux_get_proportion(tux, &x, &y, NULL, NULL); } - addToRadar(id, x, y, RADAR_TYPE_TUX); + radar_add(id, x, y, RADAR_TYPE_TUX); if (tux->bonus == BONUS_HIDDEN) { - delFromRadar(id); + radar_del(id); } - moveObjectInSpace(getCurrentArena()->spaceTux, tux, x, y); + space_move_object(arena_get_current()->spaceTux, tux, x, y); tux->status = status; tux->position = position; tux->frame = frame; @@ -578,7 +578,7 @@ void proto_send_kill_server(int type, client_t * client, tux_t * tux) snprintf(msg, STR_PROTO_SIZE, "kill %d\n", tux->id); //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } #ifndef PUBLIC_SERVER @@ -598,10 +598,10 @@ void proto_recv_kill_client(char *msg) return; } - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux != NULL) { - eventTuxIsDead(tux); + tux_event_tux_is_dead(tux); } } @@ -612,11 +612,11 @@ void proto_send_del_server(int type, client_t * client, int id) char msg[STR_PROTO_SIZE]; int check_id; - check_id = getNewIDcount(0); + check_id = id_get_newcount(0); snprintf(msg, STR_PROTO_SIZE, "del %d %d\n", id, check_id); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_CHECK, check_id); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_CHECK, check_id); //proto_check(type, client, msg, check_id); } @@ -630,12 +630,12 @@ void timer_delShot(void *p) assert( p != NULL ); id = (int *)(p); - shot = getObjectFromSpaceWithID(getCurrentArena()->spaceShot, *id); + shot = space_get_object_id(arena_get_current()->spaceShot, *id); if( shot != NULL ) { - delFromRadar(shot->id); - delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); + radar_del(shot->id); + space_del_with_item(arena_get_current()->spaceShot, shot, shot_destroy); } free(p); @@ -660,30 +660,30 @@ void proto_recv_del_client(char *msg) proto_send_check_client(check_id); - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux != NULL) { - delFromRadar(id); - delObjectFromSpaceWithObject(getCurrentArena()->spaceTux, tux, destroyTux); + radar_del(id); + space_del_with_item(arena_get_current()->spaceTux, tux, tux_destroy); return; } - shot = getObjectFromSpaceWithID(getCurrentArena()->spaceShot, id); + shot = space_get_object_id(arena_get_current()->spaceShot, id); if (shot != NULL) { //printf("delete shot..\n"); - //delFromRadar(id); - //delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_delShot, newInt(id), 50); + //radar_del(id); + //space_del_with_item(arena_get_current()->spaceShot, shot, shot_destroy); + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_delShot, newInt(id), 50); return; } - item = getObjectFromSpaceWithID(getCurrentArena()->spaceItem, id); + item = space_get_object_id(arena_get_current()->spaceItem, id); if (item != NULL) { //printf("delete item..\n"); - delFromRadar(id); - delObjectFromSpaceWithObject(getCurrentArena()->spaceItem, item, destroyItem); + radar_del(id); + space_del_with_item(arena_get_current()->spaceItem, item, item_destroy); return; } } @@ -697,14 +697,14 @@ void proto_send_additem_server(int type, client_t * client, item_t * p) assert(p != NULL); - check_id = getNewIDcount(0); + check_id = id_get_newcount(0); snprintf(msg, STR_PROTO_SIZE, "additem %d %d %d %d %d %d %d %d\n", p->id, p->type, p->x, p->y, p->count, p->frame, p->author_id, check_id); //proto_send(type, client, msg); //proto_check(type, client, msg, check_id); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_CHECK, check_id); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_CHECK, check_id); } #ifndef PUBLIC_SERVER @@ -718,7 +718,7 @@ void proto_recv_additem_client(char *msg) assert(msg != NULL); - if (getCurrentArena() == NULL) { + if (arena_get_current() == NULL) { return; } @@ -732,22 +732,22 @@ void proto_recv_additem_client(char *msg) proto_send_check_client(check_id); if ((item = - getObjectFromSpaceWithID(getCurrentArena()->spaceItem, id)) != NULL) { + space_get_object_id(arena_get_current()->spaceItem, id)) != NULL) { return; } if (type != ITEM_MINE && type != ITEM_EXPLOSION && type != ITEM_BIG_EXPLOSION) { - addToRadar(id, x, y, RADAR_TYPE_ITEM); + radar_add(id, x, y, RADAR_TYPE_ITEM); } - item = newItem(x, y, type, author_id); + item = item_new(x, y, type, author_id); - replaceItemID(item, id); + item_replace_id(item, id); item->count = count; item->frame = frame; - addObjectToSpace(getCurrentArena()->spaceItem, item); + space_add(arena_get_current()->spaceItem, item); } #endif @@ -764,7 +764,7 @@ void proto_send_shot_server(int type, client_t * client, shot_t * p) //proto_send(type, client, msg); //proto_check(type, client, msg, check_id); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } #ifndef PUBLIC_SERVER @@ -786,22 +786,22 @@ void proto_recv_shot_client(char *msg) return; } - if ((shot = getObjectFromSpaceWithID(getCurrentArena()->spaceShot, shot_id)) != NULL) { - delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); + if ((shot = space_get_object_id(arena_get_current()->spaceShot, shot_id)) != NULL) { + space_del_with_item(arena_get_current()->spaceShot, shot, shot_destroy); //return; } - shot = newShot(x, y, px, py, gun, author_id); + shot = shot_new(x, y, px, py, gun, author_id); - replaceShotID(shot, shot_id); + shot_replace_id(shot, shot_id); shot->isCanKillAuthor = isCanKillAuthor; shot->position = position; if (shot->gun == GUN_LASSER) { - transformOnlyLasser(shot); + shot_transform_lasser(shot); } - addObjectToSpace(getCurrentArena()->spaceShot, shot); + space_add(arena_get_current()->spaceShot, shot); } #endif @@ -812,7 +812,7 @@ void proto_send_chat_client(char *s) { char msg[STR_PROTO_SIZE]; snprintf(msg, STR_PROTO_SIZE, "chat %s\n", s); - sendServer(msg); + client_send(msg); } #endif @@ -836,7 +836,7 @@ void proto_recv_chat_server(client_t * client, char *msg) void proto_send_chat_server(int type, client_t * client, char *msg) { - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); #ifndef PUBLIC_SERVER proto_recv_chat_client(msg); @@ -854,7 +854,7 @@ void proto_recv_chat_client(char *msg) len = strlen(msg); msg[len - 1] = '\0'; - addToChat(msg + 5); + chat_add(msg + 5); } #endif @@ -871,14 +871,14 @@ void proto_send_module_client(char *msg) strcat(out, msg); strcat(out, "\n"); */ - sendServer(out); + client_send(out); } #endif void proto_recv_module_server(client_t * client, char *msg) { - recvMsgModule(msg + 7); + module_recv_msg(msg + 7); } void proto_send_module_server(int type, client_t * client, char *msg) @@ -892,14 +892,14 @@ void proto_send_module_server(int type, client_t * client, char *msg) strcat(out, "\n"); */ - protoSendClient(type, client, out, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, out, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } #ifndef PUBLIC_SERVER void proto_recv_module_client(char *msg) { - recvMsgModule(msg + 7); + module_recv_msg(msg + 7); } #endif @@ -910,7 +910,7 @@ void proto_send_ping_client() { char msg[STR_PROTO_SIZE]; snprintf(msg, STR_PROTO_SIZE, "ping\n"); - sendServer(msg); + client_send(msg); } #endif @@ -924,7 +924,7 @@ void proto_send_ping_server(int type, client_t * client) char msg[STR_PROTO_SIZE]; snprintf(msg, STR_PROTO_SIZE, "ping\n"); //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } #ifndef PUBLIC_SERVER @@ -946,7 +946,7 @@ void proto_send_echo_server(int type, client_t * client, char *s) snprintf(msg, STR_PROTO_SIZE, "echo%s", s); //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } void proto_send_end_server(int type, client_t * client) @@ -955,7 +955,7 @@ void proto_send_end_server(int type, client_t * client) snprintf(msg, STR_PROTO_SIZE, "end\n"); //proto_send(type, client, msg); - protoSendClient(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); + sendMsg_to_client(type, client, msg, CHECK_FRONT_TYPE_SIMPLE, CHECK_FRONT_ID_NONE); } #ifndef PUBLIC_SERVER @@ -964,7 +964,7 @@ void proto_recv_end_client(char *msg) { assert(msg != NULL); - setWorldEnd(); + word_do_end(); } #endif @@ -976,7 +976,7 @@ void proto_send_end_client() char msg[STR_PROTO_SIZE]; snprintf(msg, STR_PROTO_SIZE, "end\n"); - sendServer(msg); + client_send(msg); } #endif diff --git a/src/base/server.c b/src/base/server.c index 49a1c79..ec1a920 100644 --- a/src/base/server.c +++ b/src/base/server.c @@ -103,12 +103,12 @@ static void startUpdateServer() timeUpdate = time(NULL); } -time_t getUpdateServer() +time_t server_get_update() { return time(NULL) - timeUpdate; } -client_t *newAnyClient() +client_t *server_new_any_client() { client_t *new; @@ -116,30 +116,30 @@ client_t *newAnyClient() memset(new, 0, sizeof(client_t)); new->status = NET_STATUS_OK; - new->listRecvMsg = newList(); - new->listSendMsg = newCheckFront(); - new->listSeesShot = newList(); + new->listRecvMsg = list_new(); + new->listSendMsg = checkFront_new(); + new->listSeesShot = list_new(); new->protect = newProtect(); return new; } -void destroyAnyClient(client_t * p) +void server_destroy_any_client(client_t * p) { assert(p != NULL); - //eventMsgInCheckFront(p); - destroyListItem(p->listRecvMsg, free); - destroyListItem(p->listSeesShot, free); - destroyCheckFront(p->listSendMsg); + //checkFront_event(p); + list_destroy_item(p->listRecvMsg, free); + list_destroy_item(p->listSeesShot, free); + checkFront_destroy(p->listSendMsg); destroyProtect(p->protect); if (p->tux != NULL) { #ifdef PUBLIC_SERVER - addPlayerInHighScore(p->tux->name, p->tux->score); + table_add(p->tux->name, p->tux->score); #endif - delObjectFromSpaceWithObject(getCurrentArena()->spaceTux, p->tux, destroyTux); + space_del_with_item(arena_get_current()->spaceTux, p->tux, tux_destroy); } free(p); @@ -149,11 +149,11 @@ static void eventDelClientFromListClient(client_t * client) { int offset; - offset = searchListItem(listClient, client); + offset = list_search(listClient, client); assert(offset != -1); - delListItem(listClient, offset, destroyUdpClient); + list_del_item(listClient, offset, serverUdp_destroy_client); } static void delZombieCLient(void *p_nothink) @@ -162,14 +162,14 @@ static void delZombieCLient(void *p_nothink) my_time_t currentTime; int i; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); for (i = 0; i < listClient->count; i++) { thisClient = (client_t *) listClient->list[i]; if (isDown(thisClient->protect) == TRUE) { proto_send_end_server(PROTO_SEND_ONE, thisClient); - eventMsgInCheckFront(thisClient); + checkFront_event(thisClient); thisClient->status = NET_STATUS_ZOMBIE; } @@ -191,7 +191,7 @@ static void eventPeriodicSyncClient(void *p_nothink) int i; #ifndef PUBLIC_SERVER - proto_send_newtux_server(PROTO_SEND_ALL_SEES_TUX, NULL, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT)); + proto_send_newtux_server(PROTO_SEND_ALL_SEES_TUX, NULL, word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT)); #endif for (i = 0; i < listClient->count; i++) { @@ -212,34 +212,34 @@ static void eventSendPingClients(void *p_nothink) proto_send_ping_server(PROTO_SEND_ALL, NULL); } -void setServerTimer() +void server_set_time() { if (listServerTimer != NULL) { - destroyTimer(listServerTimer); + timer_destroy(listServerTimer); } - restartTimer(); - listServerTimer = newTimer(); + timer_restart(); + listServerTimer = timer_new(); - addTaskToTimer(listServerTimer, TIMER_PERIODIC, delZombieCLient, NULL, SERVER_TIMEOUT); - addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncClient, NULL, SERVER_TIME_SYNC); - addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventSendPingClients, NULL, SERVER_TIME_PING); + timer_add_task(listServerTimer, TIMER_PERIODIC, delZombieCLient, NULL, SERVER_TIMEOUT); + timer_add_task(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncClient, NULL, SERVER_TIME_SYNC); + timer_add_task(listServerTimer, TIMER_PERIODIC, eventSendPingClients, NULL, SERVER_TIME_PING); } -int initServer(char *ip4, int port4, char *ip6, int port6) +int server_init(char *ip4, int port4, char *ip6, int port6) { int ret; startUpdateServer(); listServerTimer = NULL; - listClient = newList(); + listClient = list_new(); - setServerMaxClients(SERVER_MAX_CLIENTS); - setServerTimer(); + server_set_max_clients(SERVER_MAX_CLIENTS); + server_set_time(); //printf("%s %d %s %d\n", ip4, port4, ip6, port6); - ret = initUdpServer(ip4, port4, ip6, port6); + ret = serverUdp_init(ip4, port4, ip6, port6); if (ret == 0) { return -1; @@ -247,32 +247,32 @@ int initServer(char *ip4, int port4, char *ip6, int port6) if( ip4 != NULL ) { - initDownServer(ip4, port4); + downServer_init(ip4, port4); } else if( ip6 != NULL ) { - initDownServer(ip6, port6); + downServer_init(ip6, port6); } return ret; } -list_t *getListServerClient() +list_t *server_get_list_clients() { return listClient; } -int getServerMaxClients() +int server_get_max_clients() { return maxClients; } -void setServerMaxClients(int n) +void server_set_max_clients(int n) { maxClients = n; } -void sendClient(client_t * p, char *msg) +void server_send_client(client_t * p, char *msg) { assert(p != NULL); assert(msg != NULL); @@ -285,7 +285,7 @@ void sendClient(client_t * p, char *msg) printf(_("Sending: \"%s\""), msg); } #endif - ret = writeUdpSocket(p->socket_udp, p->socket_udp, msg, strlen(msg)); + ret = sock_udp_write(p->socket_udp, p->socket_udp, msg, strlen(msg)); if (ret <= 0) { p->status = NET_STATUS_ZOMBIE; @@ -293,7 +293,7 @@ void sendClient(client_t * p, char *msg) } } -static void eventClientWorkRecvList(client_t * client) +static void client_eventWorkRecvList(client_t * client) { proto_cmd_server_t *protoCmd; char *line; @@ -321,8 +321,8 @@ static void eventClientWorkRecvList(client_t * client) } } - destroyListItem(client->listRecvMsg, free); - client->listRecvMsg = newList(); + list_destroy_item(client->listRecvMsg, free); + client->listRecvMsg = list_new(); } static void porcesListClients() @@ -333,60 +333,60 @@ static void porcesListClients() for (i = 0; i < listClient->count; i++) { thisClient = (client_t *) listClient->list[i]; - eventClientWorkRecvList(thisClient); - eventMsgInCheckFront(thisClient); + client_eventWorkRecvList(thisClient); + checkFront_event(thisClient); } } -void eventServer() +void server_event() { #ifndef PUBLIC_SERVER int count; do { - restartSelect(); + select_restart(); - setServerUdpSelect(); - setDownServerSelect(); + serverUdp_set_select(); + downServer_set_select(); - actionSelect(); + select_action(); - count = selectServerUdpSocket(); - selectDownServerSocket(); + count = serverUdp_select_sock(); + downServer_select_socket(); } while (count > 0); #endif #ifdef PUBLIC_SERVER int ret; - restartSelect(); + select_restart(); - setServerUdpSelect(); - setDownServerSelect(); + serverUdp_set_select(); + downServer_set_select(); - ret = actionSelect(); + ret = select_action(); if (ret > 0) { - selectServerUdpSocket(); - selectDownServerSocket(); + serverUdp_select_sock(); + downServer_select_socket(); } #endif porcesListClients(); - eventTimer(listServerTimer); + timer_event(listServerTimer); } -void quitServer() +void server_quit() { proto_send_end_server(PROTO_SEND_ALL, NULL); assert(listClient != NULL); - destroyListItem(listClient, destroyUdpClient); + list_destroy_item(listClient, serverUdp_destroy_client); - destroyTimer(listServerTimer); + timer_destroy(listServerTimer); - quitUdpServer(); + serverUdp_quit(); - quitDownServer(); + downServer_quit(); } diff --git a/src/base/server.h b/src/base/server.h index b7e9433..7768adc 100644 --- a/src/base/server.h +++ b/src/base/server.h @@ -47,16 +47,16 @@ typedef struct client_struct { list_t *listSeesShot; } client_t; -extern int initServer(char *ip4, int port4, char *ip6, int port6); -extern time_t getUpdateServer(); -extern client_t *newAnyClient(); -extern void destroyAnyClient(client_t * p); -extern list_t *getListServerClient(); -extern int getServerMaxClients(); -extern void setServerTimer(); -extern void setServerMaxClients(int n); -extern void sendClient(client_t * p, char *msg); -extern void eventServer(); -extern void quitServer(); +extern int server_init(char *ip4, int port4, char *ip6, int port6); +extern time_t server_get_update(); +extern client_t *server_new_any_client(); +extern void server_destroy_any_client(client_t * p); +extern list_t *server_get_list_clients(); +extern int server_get_max_clients(); +extern void server_set_time(); +extern void server_set_max_clients(int n); +extern void server_send_client(client_t * p, char *msg); +extern void server_event(); +extern void server_quit(); #endif diff --git a/src/base/serverSelect.c b/src/base/serverSelect.c index e25c91f..2cf2586 100644 --- a/src/base/serverSelect.c +++ b/src/base/serverSelect.c @@ -25,7 +25,7 @@ static fd_set readfds; static fd_set writefds; static int max_fd; -void restartSelect() +void select_restart() { #ifndef PUBLIC_SERVER tv.tv_sec = 0; @@ -42,9 +42,9 @@ void restartSelect() max_fd = 0; } -void addSockToSelectRead(int sock) +void select_add_sock_for_read(int sock) { - //printf("addSockToSelectRead %d\n", sock); + //printf("select_add_sock_for_read %d\n", sock); FD_SET(sock, &readfds); @@ -53,9 +53,9 @@ void addSockToSelectRead(int sock) } } -void addSockToSelectWrite(int sock) +void select_add_sock_for_write(int sock) { - //printf("addSockToSelectWrite %d\n", sock); + //printf("select_add_sock_for_write %d\n", sock); FD_SET(sock, &writefds); @@ -64,17 +64,17 @@ void addSockToSelectWrite(int sock) } } -int actionSelect() +int select_action() { int ret; #ifdef PUBLIC_SERVER list_t *listClient; - listClient = getListServerClient(); + listClient = server_get_list_clients(); if (listClient->count == 0) { ret = select(max_fd + 1, &readfds, &writefds, (fd_set *) NULL, NULL); - setServerTimer(); + server_set_time(); } else { ret = select(max_fd + 1, &readfds, &writefds, (fd_set *) NULL, &tv); } @@ -87,24 +87,24 @@ int actionSelect() return ret; } -int isChangeSockInSelectRead(int sock) +int select_is_change_sock_for_read(int sock) { int ret; ret = FD_ISSET(sock, &readfds); - //printf("isChangeSockInSelect %d -> %d\n", sock, ret); + //printf("select_is_change_sock %d -> %d\n", sock, ret); return ret; } -int isChangeSockInSelectWrite(int sock) +int select_is_change_sock_for_write(int sock) { int ret; ret = FD_ISSET(sock, &writefds); - //printf("isChangeSockInSelect %d -> %d\n", sock, ret); + //printf("select_is_change_sock %d -> %d\n", sock, ret); return ret; } diff --git a/src/base/serverSelect.h b/src/base/serverSelect.h index 390dfcc..15c8b37 100644 --- a/src/base/serverSelect.h +++ b/src/base/serverSelect.h @@ -3,12 +3,12 @@ # define SERVER_SELECT -extern void restartSelect(); -extern void addSockToSelectRead(int sock); -extern void addSockToSelectWrite(int sock); -extern int actionSelect(); -extern int isChangeSockInSelect(int sock); -extern int isChangeSockInSelectRead(int sock); -extern int isChangeSockInSelectWrite(int sock); +extern void select_restart(); +extern void select_add_sock_for_read(int sock); +extern void select_add_sock_for_write(int sock); +extern int select_action(); +extern int select_is_change_sock(int sock); +extern int select_is_change_sock_for_read(int sock); +extern int select_is_change_sock_for_write(int sock); #endif diff --git a/src/base/serverSendMsg.c b/src/base/serverSendMsg.c index e38975f..53afb8b 100644 --- a/src/base/serverSendMsg.c +++ b/src/base/serverSendMsg.c @@ -20,7 +20,7 @@ static void addMsgClient(client_t * p, char *msg, int type, int id) assert(msg != NULL); if (p->status != NET_STATUS_ZOMBIE) { - addMsgInCheckFront(p->listSendMsg, msg, type, id); + checkFront_add_msg(p->listSendMsg, msg, type, id); } } @@ -32,7 +32,7 @@ static void addMsgAllClientBut(char *msg, client_t * p, int type, int id) assert(msg != NULL); - listClient = getListServerClient(); + listClient = server_get_list_clients(); for (i = 0; i < listClient->count; i++) { thisClient = (client_t *) listClient->list[i]; @@ -60,7 +60,7 @@ static void addMsgAllClientSeesTux(char *msg, tux_t * tux, int type, int id) assert(msg != NULL); - arena = getCurrentArena(); + arena = arena_get_current(); space = arena->spaceTux; x = tux->x - WINDOW_SIZE_X; @@ -81,9 +81,9 @@ static void addMsgAllClientSeesTux(char *msg, tux_t * tux, int type, int id) if (h + y >= arena->h) h = arena->h - (y + 1); - listHelp = newList(); + listHelp = list_new(); - getObjectFromSpace(space, x, y, w, h, listHelp); + space_get_object(space, x, y, w, h, listHelp); //printf("%d %d %d %d %d\n", x, y, w, h, listHelp->count); for (i = 0; i < listHelp->count; i++) { @@ -103,10 +103,10 @@ static void addMsgAllClientSeesTux(char *msg, tux_t * tux, int type, int id) } } - destroyList(listHelp); + list_destroy(listHelp); } -void protoSendClient(int type, client_t * client, char *msg, int type2, int id) +void sendMsg_to_client(int type, client_t * client, char *msg, int type2, int id) { assert(msg != NULL); @@ -128,7 +128,7 @@ void protoSendClient(int type, client_t * client, char *msg, int type2, int id) if (client != NULL) { addMsgAllClientSeesTux(msg, client->tux, type2, id); } else { - addMsgAllClientSeesTux(msg, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT), type2, id); + addMsgAllClientSeesTux(msg, word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT), type2, id); } #endif #ifdef PUBLIC_SERVER diff --git a/src/base/serverSendMsg.h b/src/base/serverSendMsg.h index 7bb19a3..8239c7d 100644 --- a/src/base/serverSendMsg.h +++ b/src/base/serverSendMsg.h @@ -10,7 +10,7 @@ # define PROTO_SEND_BUT 3 # define PROTO_SEND_ALL_SEES_TUX 4 -extern void protoSendClient(int type, client_t * client, char *msg, int type2, +extern void sendMsg_to_client(int type, client_t * client, char *msg, int type2, int id); #endif diff --git a/src/base/shareFunction.c b/src/base/shareFunction.c index 84250a4..5d16dd0 100644 --- a/src/base/shareFunction.c +++ b/src/base/shareFunction.c @@ -31,19 +31,19 @@ static void destroyShareFce(share_fce_item_t * p) free(p); } -void initShareFunction() +void shareFunction_init() { - listShareFce = newList(); + listShareFce = list_new(); } -void addToShareFce(char *name, void *function) +void shareFunction_add(char *name, void *function) { DEBUG_MSG(_("Adding \"%s\" to share function.\n"), name); - addList(listShareFce, newShareFceItem(name, function)); + list_add(listShareFce, newShareFceItem(name, function)); } -void *getShareFce(char *name) +void *shareFunction_get(char *name) { int i; @@ -59,7 +59,7 @@ void *getShareFce(char *name) return NULL; } -void quitShareFunction() +void shareFunction_quit() { - destroyListItem(listShareFce, destroyShareFce); + list_destroy_item(listShareFce, destroyShareFce); } diff --git a/src/base/shareFunction.h b/src/base/shareFunction.h index 226c377..80384a4 100644 --- a/src/base/shareFunction.h +++ b/src/base/shareFunction.h @@ -2,8 +2,8 @@ #ifndef SHARE_FUNCTION_H # define SHARE_FUNCTION_H -extern void initShareFunction(); -extern void addToShareFce(char *name, void *function); -extern void *getShareFce(char *name); -extern void quitShareFunction(); +extern void shareFunction_init(); +extern void shareFunction_add(char *name, void *function); +extern void *shareFunction_get(char *name); +extern void shareFunction_quit(); #endif diff --git a/src/base/shot.c b/src/base/shot.c index 306527b..38ebe5e 100644 --- a/src/base/shot.c +++ b/src/base/shot.c @@ -32,29 +32,29 @@ static image_t *g_shot_bombball; static bool_t isShotInit = FALSE; -bool_t isShotInicialized() +bool_t shot_is_inicialized() { return isShotInit; } -void initShot() +void shot_init() { #ifndef PUBLIC_SERVER - assert(isImageInicialized() == TRUE); + assert(image_is_inicialized() == TRUE); #endif #ifndef PUBLIC_SERVER - g_shot_simple = addImageData("shot.png", IMAGE_ALPHA, "shot", IMAGE_GROUP_BASE); - g_shot_lasserX = addImageData("lasserX.png", IMAGE_NO_ALPHA, "lasserX", IMAGE_GROUP_BASE); - g_shot_lasserY = addImageData("lasserY.png", IMAGE_NO_ALPHA, "lasserY",IMAGE_GROUP_BASE); - g_shot_bombball = addImageData("bombball.png", IMAGE_ALPHA, "bombball", IMAGE_GROUP_BASE); + g_shot_simple = image_add("shot.png", IMAGE_ALPHA, "shot", IMAGE_GROUP_BASE); + g_shot_lasserX = image_add("lasserX.png", IMAGE_NO_ALPHA, "lasserX", IMAGE_GROUP_BASE); + g_shot_lasserY = image_add("lasserY.png", IMAGE_NO_ALPHA, "lasserY",IMAGE_GROUP_BASE); + g_shot_bombball = image_add("bombball.png", IMAGE_ALPHA, "bombball", IMAGE_GROUP_BASE); #endif isShotInit = TRUE; } -shot_t *newShot(int x, int y, int px, int py, int gun, int author_id) +shot_t *shot_new(int x, int y, int px, int py, int gun, int author_id) { shot_t *new; tux_t *author; @@ -62,7 +62,7 @@ shot_t *newShot(int x, int y, int px, int py, int gun, int author_id) new = malloc(sizeof(shot_t)); memset(new, 0, sizeof(shot_t)); - new->id = getNewID(); + new->id = id_get_new(); new->x = x; new->y = y; new->px = px; @@ -72,7 +72,7 @@ shot_t *newShot(int x, int y, int px, int py, int gun, int author_id) new->position = POSITION_UNKNOWN; - author = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, author_id); + author = space_get_object_id(arena_get_current()->spaceTux, author_id); if (author != NULL) { new->position = author->position; @@ -128,14 +128,14 @@ shot_t *newShot(int x, int y, int px, int py, int gun, int author_id) return new; } -void replaceShotID(shot_t * shot, int id) +void shot_replace_id(shot_t * shot, int id) { - replaceID(shot->id, id); + id_replace(shot->id, id); shot->id = id; } -void getStatusShot(void *p, int *id, int *x, int *y, int *w, int *h) +void shot_get_status(void *p, int *id, int *x, int *y, int *w, int *h) { shot_t *shot; @@ -147,7 +147,7 @@ void getStatusShot(void *p, int *id, int *x, int *y, int *w, int *h) *h = shot->h; } -void setStatusShot(void *p, int x, int y, int w, int h) +void shot_set_status(void *p, int x, int y, int w, int h) { shot_t *shot; @@ -160,13 +160,13 @@ void setStatusShot(void *p, int x, int y, int w, int h) #ifndef PUBLIC_SERVER -void drawShot(shot_t * p) +void shot_draw(shot_t * p) { assert(p != NULL); addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, TUX_LAYER); } -void drawListShot(list_t * listShot) +void shot_draw_list(list_t * listShot) { shot_t *thisShot; int i; @@ -176,7 +176,7 @@ void drawListShot(list_t * listShot) for (i = 0; i < listShot->count; i++) { thisShot = (shot_t *) listShot->list[i]; assert(thisShot != NULL); - drawShot(thisShot); + shot_draw(thisShot); } } @@ -203,7 +203,7 @@ static int getRandomCourse(int x, int y) return ret; } -void boundBombBall(shot_t * shot) +void shot_bound_bombBall(shot_t * shot) { if (shot->gun != GUN_BOMBBALL) { return; @@ -213,24 +213,24 @@ void boundBombBall(shot_t * shot) shot->py = getRandomCourse(shot->py, +10); shot->isCanKillAuthor = 1; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_shot_server(PROTO_SEND_ALL, NULL, shot); } } -void transformOnlyLasser(shot_t * shot) +void shot_transform_lasser(shot_t * shot) { space_t *space; int mustRefesh = 0; - space = getCurrentArena()->spaceShot; + space = arena_get_current()->spaceShot; - if (getObjectFromSpaceWithID(space, shot->id) != NULL) { + if (space_get_object_id(space, shot->id) != NULL) { mustRefesh = 1; } if (mustRefesh) { - delObjectFromSpace(space, shot); + space_del(space, shot); } switch (shot->position) { @@ -253,7 +253,7 @@ void transformOnlyLasser(shot_t * shot) } if (mustRefesh) { - addObjectToSpace(space, shot); + space_add(space, shot); } } @@ -262,22 +262,22 @@ static void action_moveShot(space_t * space, shot_t * shot, void *p) int new_x, new_y; arena_t *arena; - arena = getCurrentArena(); + arena = arena_get_current(); new_x = shot->x + shot->px; new_y = shot->y + shot->py; - moveObjectInSpace(space, shot, new_x, new_y); + space_move_object(space, shot, new_x, new_y); if (shot->x + shot->w < 0 || shot->x > arena->w || shot->y + shot->h < 0 || shot->y > arena->h) { - delObjectFromSpaceWithObject(space, shot, destroyShot); + space_del_with_item(space, shot, shot_destroy); } } -void eventMoveListShot(arena_t * arena) +void shot_event_move_list(arena_t * arena) { - actionSpace(arena->spaceShot, action_moveShot, NULL); + space_action(arena->spaceShot, action_moveShot, NULL); } static int isValueInList(list_t * list, int x) @@ -296,12 +296,12 @@ static int isValueInList(list_t * list, int x) static void action_check(space_t * space, shot_t * shot, client_t * client) { if (isValueInList(client->listSeesShot, shot->id) == 0) { - addList(client->listSeesShot, newInt(shot->id)); + list_add(client->listSeesShot, newInt(shot->id)); proto_send_shot_server(PROTO_SEND_ONE, client, shot); } } -void checkShotIsInTuxScreen(arena_t * arena) +void shot_check_is_tux_screen(arena_t * arena) { int screen_x, screen_y; tux_t *thisTux; @@ -309,11 +309,11 @@ void checkShotIsInTuxScreen(arena_t * arena) list_t *listClient; int i; - if (getNetTypeGame() != NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_SERVER) { return; } - listClient = getListServerClient(); + listClient = server_get_list_clients(); for (i = 0; i < listClient->count; i++) { thisClient = (client_t *) listClient->list[i]; @@ -324,15 +324,15 @@ void checkShotIsInTuxScreen(arena_t * arena) continue; } - getCenterScreen(&screen_x, &screen_y, thisTux->x, thisTux->y, + arena_get_center_screen(&screen_x, &screen_y, thisTux->x, thisTux->y, WINDOW_SIZE_X, WINDOW_SIZE_Y); - actionSpaceFromLocation(arena->spaceShot, action_check, + space_action_from_location(arena->spaceShot, action_check, thisClient, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); while (thisClient->listSeesShot->count > 100) { - delListItem(thisClient->listSeesShot, 0, free); + list_del_item(thisClient->listSeesShot, 0, free); del++; } @@ -340,16 +340,16 @@ void checkShotIsInTuxScreen(arena_t * arena) } } -void destroyShot(shot_t * p) +void shot_destroy(shot_t * p) { assert(p != NULL); - delID(p->id); + id_del(p->id); free(p); } -void quitShot() +void shot_quit() { isShotInit = FALSE; } diff --git a/src/base/shot.h b/src/base/shot.h index a9c04fe..3487e94 100644 --- a/src/base/shot.h +++ b/src/base/shot.h @@ -31,23 +31,23 @@ typedef struct shot_struct { # 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); +extern bool_t shot_is_inicialized(); +extern void shot_init(); +extern shot_t *shot_new(int x, int y, int px, int py, int gun, int author_id); +extern shot_t *shot_get_id(list_t * listShot, int id); +extern void shot_replace_id(shot_t * shot, int id); +extern void shot_get_status(void *p, int *id, int *x, int *y, int *w, int *h); +extern void shot_set_status(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); +extern void shot_draw(shot_t * p); +extern void shot_draw_list(list_t * listShot); # endif -extern int isConflictWithListShot(list_t * listShot, int x, int y, int w, +extern int shot_is_conflict_with_list_shot(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(); +extern void shot_event_move_list(arena_t * arena); +extern void shot_check_is_tux_screen(arena_t * arena); +extern void shot_bound_bombBall(shot_t * shot); +extern void shot_transform_lasser(shot_t * shot); +extern void shot_destroy(shot_t * p); +extern void shot_quit(); #endif diff --git a/src/base/space.c b/src/base/space.c index 2458bba..2621ecf 100644 --- a/src/base/space.c +++ b/src/base/space.c @@ -14,7 +14,7 @@ zone_t *newZone() zone_t *new; new = malloc(sizeof(zone_t)); - new->list = newList(); + new->list = list_new(); return new; } @@ -23,17 +23,17 @@ void destroyZone(zone_t * p) { assert(p != NULL); - destroyList(p->list); + list_destroy(p->list); free(p); } -static int my_conflictSpace(int x1, int y1, int w1, int h1, int x2, int y2, int w2, +static int my_arena_conflict_space(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { return (x1 < x2 + w2 && x2 < x1 + w1 && y1 < y2 + h2 && y2 < y1 + h1); } -space_t *newSpace(int w, int h, int segW, int segH, +space_t *space_new(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)) { @@ -49,7 +49,7 @@ space_t *newSpace(int w, int h, int segW, int segH, new->segH = segH; new->getStatus = getStatus; new->setStatus = setStatus; - new->listIndex = newIndex(); + new->listIndex = index_new(); new->zone = malloc(new->w * sizeof(list_t **)); @@ -75,12 +75,12 @@ static void getSegment(space_t * p, int x, int y, int w, int h, *segH = ((y + h) / p->segH + 1) - *segY; } -int getSpaceCount(space_t * p) +int space_get_count(space_t * p) { return p->listIndex->count; } -void *getItemFromSpace(space_t * p, int offset) +void *space_get_item(space_t * p, int offset) { index_item_t *this; @@ -88,7 +88,7 @@ void *getItemFromSpace(space_t * p, int offset) return this->data; } -void addObjectToSpace(space_t * p, void *item) +void space_add(space_t * p, void *item) { int segX, segY, segW, segH; int id, x, y, w, h; @@ -103,14 +103,14 @@ void addObjectToSpace(space_t * p, void *item) continue; } - addList(p->zone[j][i]->list, item); + list_add(p->zone[j][i]->list, item); } } - addToIndex(p->listIndex, id, item); + index_add(p->listIndex, id, item); } -void getObjectFromSpace(space_t * p, int x, int y, int w, int h, list_t * list) +void space_get_object(space_t * p, int x, int y, int w, int h, list_t * list) { int segX, segY, segW, segH; int id, this_x, this_y, this_w, this_h; @@ -130,21 +130,21 @@ void getObjectFromSpace(space_t * p, int x, int y, int w, int h, list_t * list) this = p->zone[j][i]->list->list[k]; p->getStatus(this, &id, &this_x, &this_y, &this_w, &this_h); - if (my_conflictSpace(x, y, w, h, this_x, this_y, this_w, this_h) && - searchListItem(list, this) == -1) { - addList(list, this); + if (my_arena_conflict_space(x, y, w, h, this_x, this_y, this_w, this_h) && + list_search(list, this) == -1) { + list_add(list, this); } } } } } -void *getObjectFromSpaceWithID(space_t * space, int id) +void *space_get_object_id(space_t * space, int id) { - return getFromIndex(space->listIndex, id); + return index_get(space->listIndex, id); } -int isConflictWithObjectFromSpace(space_t * p, int x, int y, int w, int h) +int space_is_conflict_with_object(space_t * p, int x, int y, int w, int h) { int segX, segY, segW, segH; int id, this_x, this_y, this_w, this_h; @@ -164,7 +164,7 @@ int isConflictWithObjectFromSpace(space_t * p, int x, int y, int w, int h) this = p->zone[j][i]->list->list[k]; p->getStatus(this, &id, &this_x, &this_y, &this_w, &this_h); - if (my_conflictSpace(x, y, w, h, this_x, this_y, this_w, this_h)) { + if (my_arena_conflict_space(x, y, w, h, this_x, this_y, this_w, this_h)) { return 1; } } @@ -174,7 +174,7 @@ int isConflictWithObjectFromSpace(space_t * p, int x, int y, int w, int h) return 0; } -int isConflictWithObjectFromSpaceBut(space_t * p, int x, int y, int w, int h, void *but) +int space_is_conflict_with_object_but(space_t * p, int x, int y, int w, int h, void *but) { int segX, segY, segW, segH; int id, this_x, this_y, this_w, this_h; @@ -199,7 +199,7 @@ int isConflictWithObjectFromSpaceBut(space_t * p, int x, int y, int w, int h, vo p->getStatus(this, &id, &this_x, &this_y, &this_w, &this_h); - if (my_conflictSpace(x, y, w, h, this_x, this_y, this_w, this_h)) { + if (my_arena_conflict_space(x, y, w, h, this_x, this_y, this_w, this_h)) { return 1; } } @@ -209,7 +209,7 @@ int isConflictWithObjectFromSpaceBut(space_t * p, int x, int y, int w, int h, vo return 0; } -void delObjectFromSpace(space_t * p, void *item) +void space_del(space_t * p, void *item) { int segX, segY, segW, segH; int id, x, y, w, h; @@ -225,26 +225,26 @@ void delObjectFromSpace(space_t * p, void *item) continue; } - myIndex = searchListItem(p->zone[j][i]->list, item); + myIndex = list_search(p->zone[j][i]->list, item); assert(myIndex != -1); - delList(p->zone[j][i]->list, myIndex); + list_del(p->zone[j][i]->list, myIndex); } } - delFromIndex(p->listIndex, id); + index_del(p->listIndex, id); } -void delObjectFromSpaceWithObject(space_t * p, void *item, void *f) +void space_del_with_item(space_t * p, void *item, void *f) { void (*fce) (void *param); fce = f; - delObjectFromSpace(p, item); + space_del(p, item); fce(item); } -void moveObjectInSpace(space_t * p, void *item, int move_x, int move_y) +void space_move_object(space_t * p, void *item, int move_x, int move_y) { int old_segX, old_segY, old_segW, old_segH; int new_segX, new_segY, new_segW, new_segH; @@ -260,16 +260,16 @@ void moveObjectInSpace(space_t * p, void *item, int move_x, int move_y) */ if (old_segX != new_segX || old_segY != new_segY || old_segW != new_segW || old_segH != new_segH) { - delObjectFromSpace(p, item); + space_del(p, item); p->setStatus(item, move_x, move_y, w, h); - addObjectToSpace(p, item); + space_add(p, item); return; } p->setStatus(item, move_x, move_y, w, h); } -void printSpace(space_t * p) +void space_print(space_t * p) { int i, j; @@ -284,7 +284,7 @@ void printSpace(space_t * p) } } -void actionSpace(space_t * space, void *f, void *p) +void space_action(space_t * space, void *f, void *p) { void (*fce) (space_t * space, void *f, void *p); int len; @@ -294,7 +294,7 @@ void actionSpace(space_t * space, void *f, void *p) len = space->listIndex->count; for (i = 0; i < len; i++) { - fce(space, getItemFromSpace(space, i), p); + fce(space, space_get_item(space, i), p); if (space->listIndex->count == len - 1) { len--; @@ -303,7 +303,7 @@ void actionSpace(space_t * space, void *f, void *p) } } -void actionSpaceFromLocation(space_t * space, void *f, void *p, int x, int y, int w, int h) +void space_action_from_location(space_t * space, void *f, void *p, int x, int y, int w, int h) { void (*fce) (space_t * space, void *f, void *p); list_t *list; @@ -312,9 +312,9 @@ void actionSpaceFromLocation(space_t * space, void *f, void *p, int x, int y, in fce = f; - list = newList(); + list = list_new(); - getObjectFromSpace(space, x, y, w, h, list); + space_get_object(space, x, y, w, h, list); len = list->count; @@ -322,14 +322,14 @@ void actionSpaceFromLocation(space_t * space, void *f, void *p, int x, int y, in fce(space, list->list[i], p); } - destroyList(list); + list_destroy(list); } -void destroySpace(space_t * p) +void space_destroy(space_t * p) { int j, i; - destroyIndex(p->listIndex); + index_destroy(p->listIndex); for (i = 0; i < p->h; i++) { for (j = 0; j < p->w; j++) { @@ -345,7 +345,7 @@ void destroySpace(space_t * p) free(p); } -void destroySpaceWithObject(space_t * p, void *f) +void space_destroy_with_item(space_t * p, void *f) { void (*fce) (void *param); int i; @@ -353,8 +353,8 @@ void destroySpaceWithObject(space_t * p, void *f) fce = f; for (i = 0; i < p->listIndex->count; i++) { - fce(getItemFromSpace(p, i)); + fce(space_get_item(p, i)); } - destroySpace(p); + space_destroy(p); } diff --git a/src/base/space.h b/src/base/space.h index a166c06..f4169d2 100644 --- a/src/base/space.h +++ b/src/base/space.h @@ -25,30 +25,30 @@ typedef struct space_struct { 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, +extern space_t *space_new(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 int getSpaceCount(space_t * p); -extern void *getItemFromSpace(space_t * p, int offset); -extern void addObjectToSpace(space_t * p, void *item); -extern void getObjectFromSpace(space_t * p, int x, int y, int w, int h, +extern int space_get_count(space_t * p); +extern void *space_get_item(space_t * p, int offset); +extern void space_add(space_t * p, void *item); +extern void space_get_object(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, +extern void *space_get_object_id(space_t * p, int id); +extern int space_is_conflict_with_object(space_t * p, int x, int y, int w, int h); -extern int isConflictWithObjectFromSpaceBut(space_t * p, int x, int y, int w, +extern int space_is_conflict_with_object_but(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 actionSpace(space_t * space, void *f, void *p); -extern void actionSpaceFromLocation(space_t * space, void *f, void *p, int x, +extern void space_del(space_t * p, void *item); +extern void space_del_with_item(space_t * p, void *item, void *f); +extern void space_move_object(space_t * p, void *item, int move_x, int move_y); +extern void space_print(space_t * p); +extern void space_action(space_t * space, void *f, void *p); +extern void space_action_from_location(space_t * space, void *f, void *p, int x, int y, int w, int h); -extern void destroySpace(space_t * p); -extern void destroySpaceWithObject(space_t * p, void *f); +extern void space_destroy(space_t * p); +extern void space_destroy_with_item(space_t * p, void *f); #endif diff --git a/src/base/storage.c b/src/base/storage.c index 1562fd2..99082be 100644 --- a/src/base/storage.c +++ b/src/base/storage.c @@ -13,12 +13,12 @@ typedef struct struct_storage_item { void *data; } storage_item_t; -list_t *newStorage() +list_t *storage_new() { - return newList(); + return list_new(); } -static storage_item_t *newStorageItem(char *group, char *name, void *data) +static storage_item_t *storage_new_item(char *group, char *name, void *data) { storage_item_t *new; @@ -33,7 +33,7 @@ static storage_item_t *newStorageItem(char *group, char *name, void *data) return new; } -static void destroyStorageItem(storage_item_t * p, void *f) +static void storage_destroy_item(storage_item_t * p, void *f) { void (*fce) (void *); @@ -47,16 +47,16 @@ static void destroyStorageItem(storage_item_t * p, void *f) free(p); } -void addItemToStorage(list_t * list, char *group, char *name, void *data) +void storage_add(list_t * list, char *group, char *name, void *data) { assert(list != NULL); assert(group != NULL); assert(name != NULL); - addList(list, newStorageItem(group, name, data)); + list_add(list, storage_new_item(group, name, data)); } -void *getItemFromStorage(list_t * list, char *group, char *name) +void *storage_get(list_t * list, char *group, char *name) { storage_item_t *this; int i; @@ -77,7 +77,7 @@ void *getItemFromStorage(list_t * list, char *group, char *name) return NULL; } -void delItemFromStorage(list_t * list, char *group, char *name, void *f) +void storage_del(list_t * list, char *group, char *name, void *f) { storage_item_t *this; int i; @@ -90,8 +90,8 @@ void delItemFromStorage(list_t * list, char *group, char *name, void *f) this = (storage_item_t *) list->list[i]; if (strcmp(group, this->group) == 0 && strcmp(name, this->name) == 0) { - destroyStorageItem(this, f); - delList(list, i); + storage_destroy_item(this, f); + list_del(list, i); return; } } @@ -99,7 +99,7 @@ void delItemFromStorage(list_t * list, char *group, char *name, void *f) return; } -void delAllItemFromStorage(list_t * list, char *group, void *f) +void storage_del_all(list_t * list, char *group, void *f) { storage_item_t *this; int i; @@ -111,14 +111,14 @@ void delAllItemFromStorage(list_t * list, char *group, void *f) this = (storage_item_t *) list->list[i]; if (strcmp(group, this->group) == 0) { - destroyStorageItem(this, f); - delList(list, i); + storage_destroy_item(this, f); + list_del(list, i); i--; } } } -void destroyStorage(list_t * p, void *f) +void storage_destroy(list_t * p, void *f) { storage_item_t *this; int i; @@ -129,8 +129,8 @@ void destroyStorage(list_t * p, void *f) for (i = 0; i < p->count; i++) { this = (storage_item_t *) p->list[i]; - destroyStorageItem(this, f); + storage_destroy_item(this, f); } - destroyList(p); + list_destroy(p); } diff --git a/src/base/storage.h b/src/base/storage.h index 8cf8801..dbd7fc3 100644 --- a/src/base/storage.h +++ b/src/base/storage.h @@ -5,12 +5,12 @@ # include "main.h" # include "list.h" -extern list_t *newStorage(); -extern void addItemToStorage(list_t * list, char *group, char *name, +extern list_t *storage_new(); +extern void storage_add(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, +extern void *storage_get(list_t * list, char *group, char *name); +extern void storage_del(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); +extern void storage_del_all(list_t * list, char *group, void *f); +extern void storage_destroy(list_t * p, void *f); #endif diff --git a/src/base/tcp_server.c b/src/base/tcp_server.c index b781fb5..6910b10 100644 --- a/src/base/tcp_server.c +++ b/src/base/tcp_server.c @@ -46,90 +46,90 @@ static sock_tcp_t *sock_server_tcp; static sock_tcp_t *sock_server_tcp_second; -client_t *newTcpClient(sock_tcp_t * sock_tcp) +client_t *serverTcp_new_client(sock_tcp_t * sock_tcp) { client_t *new; assert(sock_tcp != NULL); - new = newAnyClient(); + new = server_new_any_client(); new->type = CLIENT_TYPE_TCP; new->socket_tcp = sock_tcp; - new->recvBuffer = newBuffer(SERVER_TCP_BUFFER_LIMIT); - new->sendBuffer = newBuffer(SERVER_TCP_BUFFER_LIMIT); + new->recvBuffer = buffer_new(SERVER_TCP_BUFFER_LIMIT); + new->sendBuffer = buffer_new(SERVER_TCP_BUFFER_LIMIT); #ifdef PUBLIC_SERVER char str_log[STR_LOG_SIZE]; char str_ip[STR_IP_SIZE]; - getSockTcpIp(sock_tcp, str_ip, STR_IP_SIZE); + sock_tcp_get_ip(sock_tcp, str_ip, STR_IP_SIZE); sprintf(str_log, _("New client \"%s\" on port \"%d\" connected"), str_ip, - getSockTcpPort(sock_tcp)); - addToLog(LOG_INF, str_log); + sock_tcp_get_port(sock_tcp)); + log_add(LOG_INF, str_log); #endif return new; } -void sendTcpClientBuffer(client_t * client) +void serverTcp_send_client_buffer(client_t * client) { void *data; int len; int res; - len = getBufferSize(client->sendBuffer); + len = buffer_get_size(client->sendBuffer); if (len == 0) { return; } - data = getBufferData(client->sendBuffer); + data = buffer_get_data(client->sendBuffer); - res = writeTcpSocket(client->socket_tcp, data, len); - //printf("writeTcpSocket = %d\n", res); + res = sock_tcp_write(client->socket_tcp, data, len); + //printf("sock_tcp_write = %d\n", res); if (res < 0) { client->status = NET_STATUS_ZOMBIE; return; } - cutBuffer(client->sendBuffer, res); + buffer_cut(client->sendBuffer, res); } -void destroyTcpClient(client_t * client) +void serverTcp_destroy_client(client_t * client) { - eventMsgInCheckFront(client); - sendTcpClientBuffer(client); + checkFront_event(client); + serverTcp_send_client_buffer(client); #ifdef PUBLIC_SERVER char str_log[STR_LOG_SIZE]; char str_ip[STR_IP_SIZE]; - getSockTcpIp(client->socket_tcp, str_ip, STR_IP_SIZE); + sock_tcp_get_ip(client->socket_tcp, str_ip, STR_IP_SIZE); sprintf(str_log, _("Client \"%s\" on port \"%d\" disconnected"), str_ip, - getSockTcpPort(client->socket_tcp)); - addToLog(LOG_INF, str_log); + sock_tcp_get_port(client->socket_tcp)); + log_add(LOG_INF, str_log); #endif - closeTcpSocket(client->socket_tcp); - destroyBuffer(client->recvBuffer); - destroyBuffer(client->sendBuffer); + sock_tcp_close(client->socket_tcp); + buffer_destroy(client->recvBuffer); + buffer_destroy(client->sendBuffer); - destroyAnyClient(client); + server_destroy_any_client(client); } -int initTcpServer(char *ip4, int port4, char *ip6, int port6) +int serverTcp_init(char *ip4, int port4, char *ip6, int port6) { int ret; ret = 0; if (ip4 != NULL) { - sock_server_tcp = bindTcpSocket(ip4, port4, PROTO_UDPv4); + sock_server_tcp = sock_tcp_bind(ip4, port4, PROTO_UDPv4); if (sock_server_tcp != NULL) { ret++; - disableNagle(sock_server_tcp); + sock_tcp_diable_nagle(sock_server_tcp); DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\"\n"), ip4, port4); } else { @@ -139,11 +139,11 @@ int initTcpServer(char *ip4, int port4, char *ip6, int port6) } if (ip6 != NULL) { - sock_server_tcp_second = bindTcpSocket(ip6, port6, PROTO_UDPv6); + sock_server_tcp_second = sock_tcp_bind(ip6, port6, PROTO_UDPv6); if (sock_server_tcp_second != NULL) { ret++; - disableNagle(sock_server_tcp_second); + sock_tcp_diable_nagle(sock_server_tcp_second); DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\"\n"), ip6, port6); } else { @@ -161,14 +161,14 @@ static void eventNewClient(sock_tcp_t * server_sock) sock_tcp_t *sock; client_t *client; - listClient = getListServerClient(); + listClient = server_get_list_clients(); - sock = getTcpNewClient(server_sock); - disableNagle(sock); - setTcpSockNonBlock(sock); + sock = sock_tcp_accept(server_sock); + sock_tcp_diable_nagle(sock); + sock_tcp_set_non_block(sock); - client = newTcpClient(sock); - addList(listClient, client); + client = serverTcp_new_client(sock); + list_add(listClient, client); } static void eventTcpClient(client_t * client) @@ -178,37 +178,37 @@ static void eventTcpClient(client_t * client) memset(buffer, 0, STR_PROTO_SIZE); - ret = readTcpSocket(client->socket_tcp, buffer, STR_PROTO_SIZE - 1); - //printf("readTcpSocket = %d\n", ret); + ret = sock_tcp_read(client->socket_tcp, buffer, STR_PROTO_SIZE - 1); + //printf("sock_tcp_read = %d\n", ret); if (ret <= 0) { client->status = NET_STATUS_ZOMBIE; return; } - if (addBuffer(client->recvBuffer, buffer, ret) < 0) { + if (buffer_append(client->recvBuffer, buffer, ret) < 0) { client->status = NET_STATUS_ZOMBIE; return; } - while (getBufferLine(client->recvBuffer, buffer, STR_PROTO_SIZE) >= 0) { - addList(client->listRecvMsg, strdup(buffer)); + while (buffer_get_line(client->recvBuffer, buffer, STR_PROTO_SIZE) >= 0) { + list_add(client->listRecvMsg, strdup(buffer)); } } -void setServerTcpSelect() +void serverTcp_set_select() { list_t *listClient; int i; - listClient = getListServerClient(); + listClient = server_get_list_clients(); if (sock_server_tcp != NULL) { - addSockToSelectRead(sock_server_tcp->sock); + select_add_sock_for_read(sock_server_tcp->sock); } if (sock_server_tcp_second != NULL) { - addSockToSelectRead(sock_server_tcp_second->sock); + select_add_sock_for_read(sock_server_tcp_second->sock); } for (i = 0; i < listClient->count; i++) { @@ -220,11 +220,11 @@ void setServerTcpSelect() continue; } - addSockToSelectRead(client->socket_tcp->sock); + select_add_sock_for_read(client->socket_tcp->sock); } } -int selectServerTcpSocket() +int serverTcp_select_sock() { list_t *listClient; int count; @@ -233,20 +233,20 @@ int selectServerTcpSocket() count = 0; if (sock_server_tcp != NULL) { - if (isChangeSockInSelectRead(sock_server_tcp->sock)) { + if (select_is_change_sock_for_read(sock_server_tcp->sock)) { eventNewClient(sock_server_tcp); count++; } } if (sock_server_tcp_second != NULL) { - if (isChangeSockInSelectRead(sock_server_tcp_second->sock)) { + if (select_is_change_sock_for_read(sock_server_tcp_second->sock)) { eventNewClient(sock_server_tcp_second); count++; } } - listClient = getListServerClient(); + listClient = server_get_list_clients(); for (i = 0; i < listClient->count; i++) { client_t *client; @@ -257,16 +257,16 @@ int selectServerTcpSocket() continue; } - if (isChangeSockInSelectRead(client->socket_tcp->sock)) { + if (select_is_change_sock_for_read(client->socket_tcp->sock)) { //printf("sChangeSockInSelectRead\n"); eventTcpClient(client); count++; } /* - if( isChangeSockInSelectWrite(client->socket_tcp->sock) ) + if( select_is_change_sock_for_write(client->socket_tcp->sock) ) { - //printf("isChangeSockInSelectWrite\n"); - sendTcpClientBuffer(client); + //printf("select_is_change_sock_for_write\n"); + serverTcp_send_client_buffer(client); count++; } */ @@ -275,16 +275,16 @@ int selectServerTcpSocket() return count; } -void quitTcpServer() +void serverTcp_quit() { if (sock_server_tcp != NULL) { - DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockTcpPort(sock_server_tcp)); - closeTcpSocket(sock_server_tcp); + DEBUG_MSG(_("Closing port: \"%d\"\n"), sock_tcp_get_port(sock_server_tcp)); + sock_tcp_close(sock_server_tcp); } if (sock_server_tcp_second != NULL) { - DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockTcpPort(sock_server_tcp_second)); - closeTcpSocket(sock_server_tcp_second); + DEBUG_MSG(_("Closing port: \"%d\"\n"), sock_tcp_get_port(sock_server_tcp_second)); + sock_tcp_close(sock_server_tcp_second); } DEBUG_MSG("Quitting TCP\n"); diff --git a/src/base/tcp_server.h b/src/base/tcp_server.h index 592df30..8fdbedf 100644 --- a/src/base/tcp_server.h +++ b/src/base/tcp_server.h @@ -8,12 +8,12 @@ # define SERVER_TCP_BUFFER_LIMIT 4096 -extern client_t *newTcpClient(sock_tcp_t * sock_tcp); -extern void destroyTcpClient(client_t * p); -extern int initTcpServer(char *ip4, int port4, char *ip6, int port6); -extern void setServerTcpSelect(); -extern int selectServerTcpSocket(); -extern void sendTcpClientBuffer(client_t * p); -extern void quitTcpServer(); +extern client_t *serverTcp_new_client(sock_tcp_t * sock_tcp); +extern void serverTcp_destroy_client(client_t * p); +extern int serverTcp_init(char *ip4, int port4, char *ip6, int port6); +extern void serverTcp_set_select(); +extern int serverTcp_select_sock(); +extern void serverTcp_send_client_buffer(client_t * p); +extern void serverTcp_quit(); #endif diff --git a/src/base/textFile.c b/src/base/textFile.c index 222af97..5420e34 100644 --- a/src/base/textFile.c +++ b/src/base/textFile.c @@ -9,7 +9,7 @@ #include "main.h" #include "textFile.h" -textFile_t *newTextFile(char *s) +textFile_t *textFile_new(char *s) { textFile_t *new; char path[STR_PATH_SIZE]; @@ -26,7 +26,7 @@ textFile_t *newTextFile(char *s) new = malloc(sizeof(textFile_t)); new->file = strdup(path); - new->text = newList(); + new->text = list_new(); return new; } @@ -56,7 +56,7 @@ static void createLine(list_t * list, char *p, int len) memset(line, 0, (length_line + 1) * sizeof(char)); strncpy(line, begin_line, length_line); - addList(list, line); + list_add(list, line); len -= (length_line + 1); begin_line = end_line + 1; @@ -68,7 +68,7 @@ static void createLine(list_t * list, char *p, int len) * Nacita subor *s a vrati ho f * formatovany v type textFile_t* */ -textFile_t *loadTextFile(char *s) +textFile_t *textFile_load(char *s) { FILE *file; textFile_t *ret; @@ -99,7 +99,7 @@ textFile_t *loadTextFile(char *s) fclose(file); - ret = newTextFile(s); + ret = textFile_new(s); createLine(ret->text, p, file_length); free(p); @@ -111,7 +111,7 @@ textFile_t *loadTextFile(char *s) * Zobrazi text ulozeny v *p * do stdout */ -void printTextFile(textFile_t * p) +void textFile_print(textFile_t * p) { int i; @@ -124,7 +124,7 @@ void printTextFile(textFile_t * p) } } -void saveTextFile(textFile_t * p) +void textFile_save(textFile_t * p) { int i; FILE *file; @@ -144,11 +144,11 @@ void saveTextFile(textFile_t * p) * Uvolni text ulozeny v type textFile_t* * z pamate. */ -void destroyTextFile(textFile_t * p) +void textFile_destroy(textFile_t * p) { assert(p != NULL); free(p->file); - destroyListItem(p->text, free); + list_destroy_item(p->text, free); free(p); } diff --git a/src/base/textFile.h b/src/base/textFile.h index 88744e0..5af95e9 100644 --- a/src/base/textFile.h +++ b/src/base/textFile.h @@ -14,11 +14,11 @@ typedef struct str_textFile_t { 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); +extern textFile_t *textFile_new(char *s); +extern textFile_t *textFile_load(char *s); +extern void textFile_print(textFile_t * p); +extern void textFile_save(textFile_t * p); +extern void textFile_destroy(textFile_t * p); #endif diff --git a/src/base/tux.c b/src/base/tux.c index a7e330f..26f8cbb 100644 --- a/src/base/tux.c +++ b/src/base/tux.c @@ -47,23 +47,23 @@ static image_t *g_cross; static bool_t isTuxInit = FALSE; -bool_t isTuxInicialized() +bool_t tux_is_inicialized() { return isTuxInit; } -void initTux() +void tux_init() { #ifndef PUBLIC_SERVER - assert(isImageInicialized() == TRUE); + assert(image_is_inicialized() == TRUE); #endif #ifndef PUBLIC_SERVER - g_tux_up = addImageData("tux8.png", IMAGE_ALPHA, "tux8", IMAGE_GROUP_BASE); - g_tux_right = addImageData("tux6.png", IMAGE_ALPHA, "tux6", IMAGE_GROUP_BASE); - g_tux_left = addImageData("tux4.png", IMAGE_ALPHA, "tux4", IMAGE_GROUP_BASE); - g_tux_down = addImageData("tux2.png", IMAGE_ALPHA, "tux2", IMAGE_GROUP_BASE); - g_cross = addImageData("cross.png", IMAGE_ALPHA, "cross", IMAGE_GROUP_BASE); + g_tux_up = image_add("tux8.png", IMAGE_ALPHA, "tux8", IMAGE_GROUP_BASE); + g_tux_right = image_add("tux6.png", IMAGE_ALPHA, "tux6", IMAGE_GROUP_BASE); + g_tux_left = image_add("tux4.png", IMAGE_ALPHA, "tux4", IMAGE_GROUP_BASE); + g_tux_down = image_add("tux2.png", IMAGE_ALPHA, "tux2", IMAGE_GROUP_BASE); + g_cross = image_add("cross.png", IMAGE_ALPHA, "cross", IMAGE_GROUP_BASE); #endif isTuxInit = TRUE; } @@ -73,7 +73,7 @@ int getRandomGun() return random() % (GUN_BOMBBALL+1); } -tux_t *newTux() +tux_t *tux_new() { int x, y; tux_t *new; @@ -83,12 +83,12 @@ tux_t *newTux() memset(new, 0, sizeof(tux_t)); - new->id = getNewID(); + new->id = id_get_new(); new->status = TUX_STATUS_ALIVE; new->control = TUX_CONTROL_NONE; - findFreeSpace(getCurrentArena(), &x, &y, TUX_WIDTH, TUX_HEIGHT); - setTuxProportion(new, x, y); + arena_find_free_space(arena_get_current(), &x, &y, TUX_WIDTH, TUX_HEIGHT); + tux_set_proportion(new, x, y); new->position = TUX_DOWN; new->gun = getRandomGun(); @@ -109,13 +109,13 @@ tux_t *newTux() return new; } -void tuxSetName(tux_t * tux, char *name) +void tux_set_name(tux_t * tux, char *name) { strcpy(tux->name, name); //tux->g_name = getFontImage(name, COLOR_WHITE); } -bool_t isTuxAnyGun(tux_t * tux) +bool_t tux_is_any_gun(tux_t * tux) { int i; @@ -128,7 +128,7 @@ bool_t isTuxAnyGun(tux_t * tux) return FALSE; } -void getCourse(int n, int *x, int *y) +void tux_get_course(int n, int *x, int *y) { assert(x != NULL); assert(y != NULL); @@ -162,14 +162,14 @@ void getCourse(int n, int *x, int *y) #ifndef PUBLIC_SERVER -void drawTux(tux_t * tux) +void tux_draw(tux_t * tux) { image_t *g_image = NULL; assert(tux != NULL); if (tux->bonus == BONUS_HIDDEN && - getNetTypeGame() != NET_GAME_TYPE_NONE && + netMultiplayer_get_game_type() != NET_GAME_TYPE_NONE && tux->control == TUX_CONTROL_NET) { return; } @@ -233,15 +233,15 @@ void drawListTux(list_t *listTux) { thisTux = (tux_t *)listTux->list[i]; assert( thisTux != NULL ); - drawTux(thisTux); + tux_draw(thisTux); } } */ #endif -void replaceTuxID(tux_t * tux, int id) +void tux_replace_id(tux_t * tux, int id) { - replaceID(tux->id, id); + id_replace(tux->id, id); tux->id = id; } @@ -255,20 +255,20 @@ static void timer_spawnTux(void *p) id = *((int *) p); free(p); - arena = getCurrentArena(); - tux = getObjectFromSpaceWithID(arena->spaceTux, id); + arena = arena_get_current(); + tux = space_get_object_id(arena->spaceTux, id); if (tux == NULL) return; tux->status = TUX_STATUS_ALIVE; - findFreeSpace(getCurrentArena(), &x, &y, TUX_WIDTH, TUX_HEIGHT); - moveObjectInSpace(getCurrentArena()->spaceTux, tux, x, y); + arena_find_free_space(arena_get_current(), &x, &y, TUX_WIDTH, TUX_HEIGHT); + space_move_object(arena_get_current()->spaceTux, tux, x, y); tux->gun = GUN_SIMPLE; - addNewItem(arena->spaceItem, ID_UNKNOWN); + item_add_new_item(arena->spaceItem, ID_UNKNOWN); - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); } } @@ -281,7 +281,7 @@ static void timer_tuxCanShot(void *p) id = *((int *) p); free(p); - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux == NULL) return; @@ -297,7 +297,7 @@ static void timer_tuxCanSwitchGun(void *p) id = *((int *) p); free(p); - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); + tux = space_get_object_id(arena_get_current()->spaceTux, id); if (tux == NULL) return; @@ -305,14 +305,14 @@ static void timer_tuxCanSwitchGun(void *p) tux->isCanSwitchGun = TRUE; } -void eventTuxIsDead(tux_t * tux) +void tux_event_tux_is_dead(tux_t * tux) { if (tux->status == TUX_STATUS_DEAD) { return; } #ifndef NO_SOUND - playSound("dead", SOUND_GROUP_BASE); + sound_play("dead", SOUND_GROUP_BASE); #endif tux->status = TUX_STATUS_DEAD; @@ -327,22 +327,22 @@ void eventTuxIsDead(tux_t * tux) tux->isCanShot = TRUE; tux->isCanSwitchGun = TRUE; - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) { - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_spawnTux, newInt(tux->id), TUX_TIME_SPAWN); } - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_kill_server(PROTO_SEND_ALL, NULL, tux); } } -static void eventTuxIsDeadWIthShot(tux_t * tux, shot_t * shot) +static void tux_event_tux_is_deadWIthShot(tux_t * tux, shot_t * shot) { if (shot->author_id == tux->id) { tux->score--; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); } } @@ -350,37 +350,37 @@ static void eventTuxIsDeadWIthShot(tux_t * tux, shot_t * shot) if (shot->author_id != tux->id) { tux_t *author; - author = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, shot->author_id); + author = space_get_object_id(arena_get_current()->spaceTux, shot->author_id); if (author != NULL) { author->score++; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, author); } } } - countRoundInc(); - eventTuxIsDead(tux); + word_inc_round(); + tux_event_tux_is_dead(tux); } -void tuxTeleport(tux_t * tux) +void tux_teleport(tux_t * tux) { int x, y; #ifndef NO_SOUND - playSound("teleport", SOUND_GROUP_BASE); + sound_play("teleport", SOUND_GROUP_BASE); #endif - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) { - findFreeSpace(getCurrentArena(), &x, &y, TUX_WIDTH, TUX_HEIGHT); - moveObjectInSpace(getCurrentArena()->spaceTux, tux, x, y); - //setTuxProportion(tux, x, y); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { + arena_find_free_space(arena_get_current(), &x, &y, TUX_WIDTH, TUX_HEIGHT); + space_move_object(arena_get_current()->spaceTux, tux, x, y); + //tux_set_proportion(tux, x, y); } - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); } } @@ -393,23 +393,23 @@ static void bombBallExplosion(shot_t * shot) x = (shot->x + shot->w / 2) - ITEM_BIG_EXPLOSION_WIDTH / 2; y = (shot->y + shot->h / 2) - ITEM_BIG_EXPLOSION_HEIGHT / 2; - item = newItem(x, y, ITEM_BIG_EXPLOSION, shot->author_id); + item = item_new(x, y, ITEM_BIG_EXPLOSION, shot->author_id); - addObjectToSpace(getCurrentArena()->spaceItem, item); + space_add(arena_get_current()->spaceItem, item); - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_del_server(PROTO_SEND_ALL, NULL, shot->id); proto_send_additem_server(PROTO_SEND_ALL, NULL, item); } - delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); + space_del_with_item(arena_get_current()->spaceShot, shot, shot_destroy); } static void action_tux(space_t * space, tux_t * tux, shot_t * shot) { arena_t *arena; - arena = getCurrentArena(); + arena = arena_get_current(); if (tux->status == TUX_STATUS_ALIVE) { if (shot->author_id == tux->id && shot->isCanKillAuthor == FALSE) { @@ -417,42 +417,42 @@ static void action_tux(space_t * space, tux_t * tux, shot_t * shot) } if (tux->bonus == BONUS_TELEPORT) { - tuxTeleport(tux); + tux_teleport(tux); return; } if (shot->gun == GUN_BOMBBALL) { - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) { + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { bombBallExplosion(shot); } return; } - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) { - eventTuxIsDeadWIthShot(tux, shot); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { + tux_event_tux_is_deadWIthShot(tux, shot); } } - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_del_server(PROTO_SEND_ALL, NULL, shot->id); } - delObjectFromSpaceWithObject(arena->spaceShot, shot, destroyShot); + space_del_with_item(arena->spaceShot, shot, shot_destroy); } static void action_shot(space_t * space, shot_t * shot, space_t * spaceTux) { - actionSpaceFromLocation(spaceTux, action_tux, shot, shot->x, shot->y, shot->w, shot->h); + space_action_from_location(spaceTux, action_tux, shot, shot->x, shot->y, shot->w, shot->h); } -void eventConflictTuxWithShot(arena_t * arena) +void tux_conflict_woth_shot(arena_t * arena) { - if (getNetTypeGame() == NET_GAME_TYPE_CLIENT) { // na skusku + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { // na skusku return; } - actionSpace(arena->spaceShot, action_shot, arena->spaceTux); + space_action(arena->spaceShot, action_shot, arena->spaceTux); } void moveTux(tux_t * tux, int n) @@ -465,7 +465,7 @@ void moveTux(tux_t * tux, int n) assert(tux != NULL); - arena = getCurrentArena(); + arena = arena_get_current(); //interval(); if (tux->position != n) { @@ -480,9 +480,9 @@ void moveTux(tux_t * tux, int n) return; } - getTuxProportion(tux, &zal_x, &zal_y, &w, &h); + tux_get_proportion(tux, &zal_x, &zal_y, &w, &h); - getCourse(tux->position, &px, &py); + tux_get_course(tux->position, &px, &py); new_x = zal_x; new_y = zal_y; @@ -496,15 +496,15 @@ void moveTux(tux_t * tux, int n) } if (tux->bonus != BONUS_GHOST && - ( isConflictWithObjectFromSpaceBut(arena->spaceTux, new_x, new_y, w, h, tux) || - isConflictModule(new_x, new_y, w, h))) { - setTuxProportion(tux, zal_x, zal_y); + ( space_is_conflict_with_object_but(arena->spaceTux, new_x, new_y, w, h, tux) || + module_is_conflict(new_x, new_y, w, h))) { + tux_set_proportion(tux, zal_x, zal_y); return; } - setTuxProportion(tux, zal_x, zal_y); - moveObjectInSpace(arena->spaceTux, tux, new_x, new_y); - eventGiveTuxListItem(tux, getCurrentArena()->spaceItem); + tux_set_proportion(tux, zal_x, zal_y); + space_move_object(arena->spaceTux, tux, new_x, new_y); + item_tux_give_list_item(tux, arena_get_current()->spaceItem); tux->frame++; if (tux->frame == TUX_KEY * TUX_MAX_ANIMATION_FRAME) @@ -523,11 +523,11 @@ void switchTuxGun(tux_t * tux) if (tux->shot[i] > 0) { tux->gun = i; tux->isCanSwitchGun = FALSE; - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_tuxCanSwitchGun, newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN); #ifndef NO_SOUND - playSound("switch_gun", SOUND_GROUP_BASE); + sound_play("switch_gun", SOUND_GROUP_BASE); #endif return; } @@ -538,12 +538,12 @@ void switchTuxGun(tux_t * tux) tux->gun = i; tux->isCanSwitchGun = FALSE; - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_tuxCanSwitchGun, newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN); #ifndef NO_SOUND - playSound("switch_gun", SOUND_GROUP_BASE); + sound_play("switch_gun", SOUND_GROUP_BASE); #endif return; } @@ -559,14 +559,14 @@ void shotTux(tux_t * tux) } #ifndef NO_SOUND - playSound("switch_gun", SOUND_GROUP_BASE); + sound_play("switch_gun", SOUND_GROUP_BASE); #endif - shotInGun(tux); + gun_shot(tux); tux->isCanShot = FALSE; - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanShot, + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_tuxCanShot, newInt(tux->id), TUX_TIME_CAN_SHOT); if (tux->shot[tux->gun] == 0) { @@ -574,7 +574,7 @@ void shotTux(tux_t * tux) } } -void actionTux(tux_t * tux, int action) +void tux_action(tux_t * tux, int action) { if (tux->status == TUX_STATUS_DEAD) { return; @@ -600,23 +600,23 @@ void actionTux(tux_t * tux, int action) static void pickUpGun(tux_t * tux) { - if (isTuxAnyGun(tux) == FALSE) { + if (tux_is_any_gun(tux) == FALSE) { tux->gun = GUN_SIMPLE; if (tux->pickup_time < TUX_MAX_PICKUP) { tux->pickup_time++; } - if (tux->pickup_time == TUX_MAX_PICKUP && getNetTypeGame() != NET_GAME_TYPE_CLIENT) { + if (tux->pickup_time == TUX_MAX_PICKUP && netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { #ifndef NO_SOUND - playSound("switch_gun", SOUND_GROUP_BASE); + sound_play("switch_gun", SOUND_GROUP_BASE); #endif tux->gun = GUN_SIMPLE; tux->shot[tux->gun] = GUN_MAX_SHOT; tux->pickup_time = 0; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); } } @@ -630,15 +630,15 @@ static void eventBonus(tux_t * tux) tux->bonus_time--; } - if (tux->bonus_time == 0 && getNetTypeGame() != NET_GAME_TYPE_CLIENT) { + if (tux->bonus_time == 0 && netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { if (tux->bonus == BONUS_GHOST) { int x, y, w, h; - getTuxProportion(tux, &x, &y, &w, &h); + tux_get_proportion(tux, &x, &y, &w, &h); tux->bonus = BONUS_NONE; - if ( /*isConflictTuxWithListTux(tux, getCurrentArena()->listTux) || */ - isConflictModule(x, y, w, h)) { + if ( /*isConflictTuxWithListTux(tux, arena_get_current()->listTux) || */ + module_is_conflict(x, y, w, h)) { tux->bonus = BONUS_GHOST; return; } @@ -646,25 +646,25 @@ static void eventBonus(tux_t * tux) tux->bonus = BONUS_NONE; - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); } } } } -void eventTux(tux_t * tux) +void tux_event(tux_t * tux) { arena_t *arena; - arena = getCurrentArena(); + arena = arena_get_current(); #ifndef PUBLIC_SERVER - tuxControl(tux); + word_tux_control(tux); #endif pickUpGun(tux); eventBonus(tux); - eventGiveTuxListItem(tux, arena->spaceItem); + item_tux_give_list_item(tux, arena->spaceItem); } /* @@ -679,11 +679,11 @@ void eventListTux(list_t *listTux) { thisTux = (tux_t *)listTux->list[i]; assert( thisTux != NULL ); - eventTux(thisTux); + tux_event(thisTux); } } */ -void getTuxProportion(tux_t * tux, int *x, int *y, int *w, int *h) +void tux_get_proportion(tux_t * tux, int *x, int *y, int *w, int *h) { assert(tux != NULL); @@ -700,7 +700,7 @@ void getTuxProportion(tux_t * tux, int *x, int *y, int *w, int *h) *h = TUX_HEIGHT; } -void setTuxProportion(tux_t * tux, int x, int y) +void tux_set_proportion(tux_t * tux, int x, int y) { assert(tux != NULL); @@ -708,21 +708,21 @@ void setTuxProportion(tux_t * tux, int x, int y) tux->y = y + TUX_WIDTH / 2; } -void getStatusTux(void *p, int *id, int *x, int *y, int *w, int *h) +void tux_get_status(void *p, int *id, int *x, int *y, int *w, int *h) { tux_t *tux; tux = p; *id = tux->id; - getTuxProportion(tux, x, y, w, h); + tux_get_proportion(tux, x, y, w, h); } -void setStatusTux(void *p, int x, int y, int w, int h) +void tux_set_status(void *p, int x, int y, int w, int h) { tux_t *tux; tux = p; - setTuxProportion(tux, x, y); + tux_set_proportion(tux, x, y); } static void action_checkMine(space_t * space, item_t * item, tux_t * tux) @@ -732,22 +732,22 @@ static void action_checkMine(space_t * space, item_t * item, tux_t * tux) } } -void destroyTux(tux_t * tux) +void tux_destroy(tux_t * tux) { arena_t *arena; - arena = getCurrentArena(); + arena = arena_get_current(); assert(tux != NULL); - delID(tux->id); + id_del(tux->id); - actionSpace(arena->spaceItem, action_checkMine, tux); + space_action(arena->spaceItem, action_checkMine, tux); free(tux); } -void quitTux() +void tux_quit() { isTuxInit = FALSE; } diff --git a/src/base/tux.h b/src/base/tux.h index ae86c71..d2d9ea4 100644 --- a/src/base/tux.h +++ b/src/base/tux.h @@ -108,30 +108,30 @@ typedef struct tux_struct { void *client; } tux_t; -extern bool_t isTuxInicialized(); -extern void initTux(); -extern tux_t *newTux(); -extern void tuxSetName(tux_t * tux, char *name); -extern bool_t isTuxAnyGun(tux_t * tux); -extern void getCourse(int n, int *x, int *y); -extern void drawTux(tux_t * tux); +extern bool_t tux_is_inicialized(); +extern void tux_init(); +extern tux_t *tux_new(); +extern void tux_set_name(tux_t * tux, char *name); +extern bool_t tux_is_any_gun(tux_t * tux); +extern void tux_get_course(int n, int *x, int *y); +extern void tux_draw(tux_t * tux); //extern void drawListTux(list_t *listTux); -extern void eventTuxIsDead(tux_t * tux); +extern void tux_event_tux_is_dead(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 tux_conflict_woth_shot(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 eventTux(tux_t * tux); +extern void tux_teleport(tux_t * tux); +extern void tux_action(tux_t * tux, int action); +extern void tux_event(tux_t * tux); //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 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(); +extern void tux_get_proportion(tux_t * tux, int *x, int *y, int *w, int *h); +extern void tux_replace_id(tux_t * tux, int id); +extern void tux_set_proportion(tux_t * tux, int x, int y); +extern void tux_get_status(void *p, int *id, int *x, int *y, int *w, int *h); +extern void tux_set_status(void *p, int x, int y, int w, int h); +extern void tux_destroy(tux_t * tux); +extern void tux_quit(); #endif diff --git a/src/base/udp_server.c b/src/base/udp_server.c index b61cfef..3128992 100644 --- a/src/base/udp_server.c +++ b/src/base/udp_server.c @@ -46,13 +46,13 @@ static sock_udp_t *sock_server_udp; static sock_udp_t *sock_server_udp_second; -client_t *newUdpClient(sock_udp_t * sock_udp) +client_t *serverUdp_new_client(sock_udp_t * sock_udp) { client_t *new; assert(sock_udp != NULL); - new = newAnyClient(); + new = server_new_any_client(); new->type = CLIENT_TYPE_UDP; new->socket_udp = sock_udp; @@ -60,40 +60,40 @@ client_t *newUdpClient(sock_udp_t * sock_udp) char str_log[STR_LOG_SIZE]; char str_ip[STR_IP_SIZE]; - getSockUdpIp(sock_udp, str_ip, STR_IP_SIZE); - sprintf(str_log, _("New client \"%s\" on port \"%d\" connected"), str_ip, getSockUdpPort(sock_udp)); - addToLog(LOG_INF, str_log); + sock_udp_get_ip(sock_udp, str_ip, STR_IP_SIZE); + sprintf(str_log, _("New client \"%s\" on port \"%d\" connected"), str_ip, sock_udp_get_port(sock_udp)); + log_add(LOG_INF, str_log); #endif return new; } -void destroyUdpClient(client_t * p) +void serverUdp_destroy_client(client_t * p) { - eventMsgInCheckFront(p); + checkFront_event(p); #ifdef PUBLIC_SERVER char str_log[STR_LOG_SIZE]; char str_ip[STR_IP_SIZE]; - getSockUdpIp(p->socket_udp, str_ip, STR_IP_SIZE); - sprintf(str_log, _("Client \"%s\" on port \"%d\" disconnected"), str_ip, getSockUdpPort(p->socket_udp)); - addToLog(LOG_INF, str_log); + sock_udp_get_ip(p->socket_udp, str_ip, STR_IP_SIZE); + sprintf(str_log, _("Client \"%s\" on port \"%d\" disconnected"), str_ip, sock_udp_get_port(p->socket_udp)); + log_add(LOG_INF, str_log); #endif - destroySockUdp(p->socket_udp); + sock_udp_destroy(p->socket_udp); - destroyAnyClient(p); + server_destroy_any_client(p); } -int initUdpServer(char *ip4, int port4, char *ip6, int port6) +int serverUdp_init(char *ip4, int port4, char *ip6, int port6) { int ret; ret = 0; if (ip4 != NULL) { - sock_server_udp = bindUdpSocket(ip4, port4); + sock_server_udp = sock_udp_bind(ip4, port4); if (sock_server_udp != NULL) { ret++; @@ -104,7 +104,7 @@ int initUdpServer(char *ip4, int port4, char *ip6, int port6) } if (ip6 != NULL) { - sock_server_udp_second = bindUdpSocket(ip6, port6); + sock_server_udp_second = sock_udp_bind(ip6, port6); if (sock_server_udp_second != NULL) { ret++; @@ -124,10 +124,10 @@ static void eventCreateNewUdpClient(sock_udp_t * socket_udp) assert(socket_udp != NULL); - listClient = getListServerClient(); + listClient = server_get_list_clients(); - client = newUdpClient(socket_udp); - addList(listClient, client); + client = serverUdp_new_client(socket_udp); + list_add(listClient, client); } static client_t *findUdpClient(sock_udp_t * sock_udp) @@ -136,8 +136,8 @@ static client_t *findUdpClient(sock_udp_t * sock_udp) int port; int i; - port = getSockUdpPort(sock_udp); - listClient = getListServerClient(); + port = sock_udp_get_port(sock_udp); + listClient = server_get_list_clients(); for (i = 0; i < listClient->count; i++) { client_t *client; @@ -145,7 +145,7 @@ static client_t *findUdpClient(sock_udp_t * sock_udp) client = (client_t *) listClient->list[i]; if (client->type == CLIENT_TYPE_UDP && - getSockUdpPort(client->socket_udp) == port) { + sock_udp_get_port(client->socket_udp) == port) { return client; } } @@ -153,7 +153,7 @@ static client_t *findUdpClient(sock_udp_t * sock_udp) return NULL; } -static void eventClientUdpSelect(sock_udp_t * sock_server) +static void client_eventUdpSelect(sock_udp_t * sock_server) { sock_udp_t *sock_client; client_t *client; @@ -163,12 +163,12 @@ static void eventClientUdpSelect(sock_udp_t * sock_server) assert(sock_server != NULL); - sock_client = newSockUdp(); + sock_client = sock_udp_new(); isCreateNewClient = FALSE; memset(listRecvMsg, 0, STR_SIZE); - ret = readUdpSocket(sock_server, sock_client, listRecvMsg, STR_SIZE - 1); + ret = sock_udp_read(sock_server, sock_client, listRecvMsg, STR_SIZE - 1); client = findUdpClient(sock_client); @@ -184,7 +184,7 @@ static void eventClientUdpSelect(sock_udp_t * sock_server) } if (isCreateNewClient == FALSE) { - destroySockUdp(sock_client); + sock_udp_destroy(sock_client); } if (ret <= 0) { @@ -193,36 +193,36 @@ static void eventClientUdpSelect(sock_udp_t * sock_server) } //printf("add packet >>%s<<\n", listRecvMsg); - addList(client->listRecvMsg, strdup(listRecvMsg)); + list_add(client->listRecvMsg, strdup(listRecvMsg)); } -void setServerUdpSelect() +void serverUdp_set_select() { if (sock_server_udp != NULL) { - addSockToSelectRead(sock_server_udp->sock); + select_add_sock_for_read(sock_server_udp->sock); } if (sock_server_udp_second != NULL) { - addSockToSelectRead(sock_server_udp_second->sock); + select_add_sock_for_read(sock_server_udp_second->sock); } } -int selectServerUdpSocket() +int serverUdp_select_sock() { int count; count = 0; if (sock_server_udp != NULL) { - if (isChangeSockInSelectRead(sock_server_udp->sock)) { - eventClientUdpSelect(sock_server_udp); + if (select_is_change_sock_for_read(sock_server_udp->sock)) { + client_eventUdpSelect(sock_server_udp); count++; } } if (sock_server_udp_second != NULL) { - if (isChangeSockInSelectRead(sock_server_udp_second->sock)) { - eventClientUdpSelect(sock_server_udp_second); + if (select_is_change_sock_for_read(sock_server_udp_second->sock)) { + client_eventUdpSelect(sock_server_udp_second); count++; } } @@ -230,16 +230,16 @@ int selectServerUdpSocket() return count; } -void quitUdpServer() +void serverUdp_quit() { if (sock_server_udp != NULL) { - DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockUdpPort(sock_server_udp)); - closeUdpSocket(sock_server_udp); + DEBUG_MSG(_("Closing port: \"%d\"\n"), sock_udp_get_port(sock_server_udp)); + sock_udp_close(sock_server_udp); } if (sock_server_udp_second != NULL) { - DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockUdpPort(sock_server_udp_second)); - closeUdpSocket(sock_server_udp_second); + DEBUG_MSG(_("Closing port: \"%d\"\n"), sock_udp_get_port(sock_server_udp_second)); + sock_udp_close(sock_server_udp_second); } DEBUG_MSG(_("Quitting UDP\n")); diff --git a/src/base/udp_server.h b/src/base/udp_server.h index 25d680d..4d0245c 100644 --- a/src/base/udp_server.h +++ b/src/base/udp_server.h @@ -6,11 +6,11 @@ # include "server.h" # include "udp.h" -extern client_t *newUdpClient(sock_udp_t * sock_udp); -extern void destroyUdpClient(client_t * p); -extern int initUdpServer(char *ip4, int port4, char *ip6, int port6); -extern void setServerUdpSelect(); -extern int selectServerUdpSocket(); -extern void quitUdpServer(); +extern client_t *serverUdp_new_client(sock_udp_t * sock_udp); +extern void serverUdp_destroy_client(client_t * p); +extern int serverUdp_init(char *ip4, int port4, char *ip6, int port6); +extern void serverUdp_set_select(); +extern int serverUdp_select_sock(); +extern void serverUdp_quit(); #endif diff --git a/src/client/chat.c b/src/client/chat.c index b446b08..e071b17 100644 --- a/src/client/chat.c +++ b/src/client/chat.c @@ -33,13 +33,13 @@ static bool_t receivedNewMsg; static void hotkey_chat_enter(); static void hotkey_chat_enter(); -static void eventChatDisable(); +static void chat_eventDisable(); static void hotkey_chat_esc() { //printf("*** hotkey_chat_esc\n"); - //unregisterHotKey(SDLK_ESCAPE); - eventChatDisable(); + //unhotKey_register(SDLK_ESCAPE); + chat_eventDisable(); } static void hotkey_chat_enter() @@ -52,23 +52,23 @@ static void hotkey_chat_enter() chat_active = TRUE; receivedNewMsg = FALSE; - disableHotKey(SDLK_RETURN); - disableHotKey(SDLK_p); - registerHotKey(SDLK_ESCAPE, hotkey_chat_esc); + hotKey_disable(SDLK_RETURN); + hotKey_disable(SDLK_p); + hotKey_register(SDLK_ESCAPE, hotkey_chat_esc); - enableKeyboardBuffer(); - clearKeyboardBuffer(); + interface_enable_keyboard_buffer(); + keyboardBuffer_clear(); } -void initChat() +void chat_init() { - g_chat = addImageData("chat.png", IMAGE_NO_ALPHA, "chat", IMAGE_GROUP_USER); + g_chat = image_add("chat.png", IMAGE_NO_ALPHA, "chat", IMAGE_GROUP_USER); - listText = newList(); + listText = list_new(); strcpy(line, ""); chat_active = FALSE; - registerHotKey(SDLK_RETURN, hotkey_chat_enter); + hotKey_register(SDLK_RETURN, hotkey_chat_enter); receivedNewMsg = FALSE; line_time = 0; @@ -76,7 +76,7 @@ void initChat() timeBlick = 0; } -void drawChat() +void chat_draw() { char str[STR_SIZE]; int i; @@ -85,7 +85,7 @@ void drawChat() return; } - drawImage(g_chat, CHAT_LOCATION_X, CHAT_LOCATION_Y, + image_draw(g_chat, CHAT_LOCATION_X, CHAT_LOCATION_Y, 0, 0, CHAT_SIZE_X, CHAT_SIZE_Y); for (i = 0; i < listText->count; i++) { @@ -93,7 +93,7 @@ void drawChat() s = (char *) listText->list[i]; - drawFontMaxSize(s, CHAT_LOCATION_X + 5, CHAT_LOCATION_Y + 5 + i * 20, + font_drawMaxSize(s, CHAT_LOCATION_X + 5, CHAT_LOCATION_Y + 5 + i * 20, CHAT_SIZE_X - 10, 20, COLOR_WHITE); } @@ -109,7 +109,7 @@ void drawChat() timeBlick = 0; } - drawFont(str, CHAT_LOCATION_X + 5, (CHAT_LOCATION_Y + 5) + (CHAT_MAX_LINES * 20), COLOR_WHITE); + font_draw(str, CHAT_LOCATION_X + 5, (CHAT_LOCATION_Y + 5) + (CHAT_MAX_LINES * 20), COLOR_WHITE); } static void processMessageKey(SDL_keysym keysym) @@ -122,7 +122,7 @@ static void processMessageKey(SDL_keysym keysym) line_atime++; len = strlen(line); - getTextSize(line, &w, &h); + font_text_size(line, &w, &h); if (w > CHAT_SIZE_X - 40) { return; @@ -160,42 +160,42 @@ static void processMessageKey(SDL_keysym keysym) static void sendNewMessage() { - if (getNetTypeGame() == NET_GAME_TYPE_CLIENT) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { proto_send_chat_client(line); } - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { char out[STR_PROTO_SIZE]; snprintf(out, STR_PROTO_SIZE, "chat %s:%s\n", - getControlTux(TUX_CONTROL_KEYBOARD_RIGHT)->name, line); + word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT)->name, line); proto_send_chat_server(PROTO_SEND_ALL, NULL, out); } } -static void eventChatDisable() +static void chat_eventDisable() { chat_active = FALSE; memset(line, '\0', STR_SIZE); - enableHotKey(SDLK_RETURN); - enableHotKey(SDLK_p); - unregisterHotKey(SDLK_ESCAPE); + hotKey_enable(SDLK_RETURN); + hotKey_enable(SDLK_p); + unhotKey_register(SDLK_ESCAPE); - disableKeyboardBuffer(); - clearKeyboardBuffer(); + interface_disable_keyboard_buffer(); + keyboardBuffer_clear(); } -static void eventChatEnable() +static void chat_eventEnable() { /* The chat window is displayed. It is needed to process all keys in the buffer * but when ENTER is pressed the chat row is sent to the server */ - while (isAnyKeyInKeyboardBuffer() == TRUE) { + while (keyboardBuffer_is_any_key() == TRUE) { SDL_keysym key; - key = popKeyFromKeyboardBuffer(); + key = keyboardBuffer_pop(); if (key.sym == SDLK_RETURN) { if (strcmp(line, "") != 0) { @@ -205,10 +205,10 @@ static void eventChatEnable() continue; /* continue with other keys */ } else { /* the chat row is empty - it is needed to turn off the chat window */ - //eventChatDisable(); + //chat_eventDisable(); /* turn off key catching into the buffer and clear the buffer */ - //disableKeyboardBuffer(); - //clearKeyboardBuffer(); + //interface_disable_keyboard_buffer(); + //keyboardBuffer_clear(); } } @@ -219,29 +219,29 @@ static void eventChatEnable() /** * Processing of chat 'events' */ -void eventChat() +void chat_event() { - if (isChatActive()) { - eventChatEnable(); + if (chat_is_active()) { + chat_eventEnable(); } } -bool_t isChatActive() +bool_t chat_is_active() { return chat_active; } -bool_t isRecivedNewMsg() +bool_t chat_is_recived_new_msg() { return receivedNewMsg; } -void addToChat(char *s) +void chat_add(char *s) { - addList(listText, strdup(s)); + list_add(listText, strdup(s)); if (listText->count > CHAT_MAX_LINES) { - delListItem(listText, 0, free); + list_del_item(listText, 0, free); } if (chat_active == FALSE) { @@ -249,10 +249,10 @@ void addToChat(char *s) } } -void quitChat() +void chat_quit() { assert(listText != NULL); - //unregisterHotKey(SDLK_RETURN); - destroyListItem(listText, free); + //unhotKey_register(SDLK_RETURN); + list_destroy_item(listText, free); } diff --git a/src/client/chat.h b/src/client/chat.h index 9022466..a11b286 100644 --- a/src/client/chat.h +++ b/src/client/chat.h @@ -14,12 +14,12 @@ # define CHAT_LOCATION_X (WINDOW_SIZE_X/2 - CHAT_SIZE_X/2) # define CHAT_LOCATION_Y (WINDOW_SIZE_Y/2 - CHAT_SIZE_Y/2) -extern void initChat(); -extern void drawChat(); -extern void eventChat(); -extern void addToChat(char *s); -extern bool_t isChatActive(); -extern bool_t isRecivedNewMsg(); -extern void quitChat(); +extern void chat_init(); +extern void chat_draw(); +extern void chat_event(); +extern void chat_add(char *s); +extern bool_t chat_is_active(); +extern bool_t chat_is_recived_new_msg(); +extern void chat_quit(); #endif diff --git a/src/client/client.c b/src/client/client.c index 5aa995b..3663264 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -90,7 +90,7 @@ static proto_cmd_client_t *findCmdProto(char *msg) static int initUdpClient(char *ip, int port) { - sock_server_udp = connectUdpSocket(ip, port); + sock_server_udp = sock_udp_connect(ip, port); if (sock_server_udp == NULL) { return -1; @@ -101,23 +101,23 @@ static int initUdpClient(char *ip, int port) return 0; } -int initClient(char *ip, int port) +int client_init(char *ip, int port) { char name[STR_NAME_SIZE]; int ret; - listRecvMsg = newList(); - lastPing = getMyTime(); - lastPingServerAlive = getMyTime(); + listRecvMsg = list_new(); + lastPing = timer_get_current_time(); + lastPingServerAlive = timer_get_current_time(); #ifdef SUPPORT_TRAFFIC - lastTraffic = getMyTime(); + lastTraffic = timer_get_current_time(); traffic_down = 0; traffic_up = 0; #endif - clientRecvBuffer = newBuffer(CLIENT_BUFFER_LIMIT); - clientSendBuffer = newBuffer(CLIENT_BUFFER_LIMIT); + clientRecvBuffer = buffer_new(CLIENT_BUFFER_LIMIT); + clientSendBuffer = buffer_new(CLIENT_BUFFER_LIMIT); ret = initUdpClient(ip, port); @@ -125,7 +125,7 @@ int initClient(char *ip, int port) return -1; } - getSettingNameRight(name); + publicServer_get_settingNameRight(name); proto_send_hello_client(name); return 0; @@ -134,11 +134,11 @@ int initClient(char *ip, int port) static void errorWithServer() { fprintf(stderr, _("Server did not respond!\n")); - setMsgToAnalyze(_("Server is not running or being blocked. I was unable to connect.")); - setWorldEnd(); + analyze_set_msg(_("Server is not running or being blocked. I was unable to connect.")); + word_do_end(); } -void sendServer(char *msg) +void client_send(char *msg) { int ret; @@ -157,7 +157,7 @@ void sendServer(char *msg) #endif if (sock_server_udp != NULL) { - ret = writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg)); + ret = sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg)); } if (ret < 0) { @@ -166,7 +166,7 @@ void sendServer(char *msg) } } -static int eventServerSelect() +static int server_eventSelect() { char buffer[STR_PROTO_SIZE]; int ret; @@ -175,7 +175,7 @@ static int eventServerSelect() ret = -1; if (sock_server_udp != NULL) { - ret = readUdpSocket(sock_server_udp, sock_server_udp, buffer, STR_PROTO_SIZE - 1); + ret = sock_udp_read(sock_server_udp, sock_server_udp, buffer, STR_PROTO_SIZE - 1); } if (ret < 0) { @@ -187,17 +187,17 @@ static int eventServerSelect() traffic_down += ret; #endif - addList(listRecvMsg, strdup(buffer)); + list_add(listRecvMsg, strdup(buffer)); #if 0 - if (addBuffer(clientRecvBuffer, buffer, ret) < 0) { + if (buffer_append(clientRecvBuffer, buffer, ret) < 0) { errorWithServer(); return ret; } - while (getBufferLine(clientRecvBuffer, buffer, STR_PROTO_SIZE) >= 0) { + while (buffer_get_line(clientRecvBuffer, buffer, STR_PROTO_SIZE) >= 0) { if (strlen(buffer) > 0) { - addList(listRecvMsg, strdup(buffer)); + list_add(listRecvMsg, strdup(buffer)); } } #endif @@ -205,7 +205,7 @@ static int eventServerSelect() return ret; } -static void eventClientWorkRecvList() +static void client_eventWorkRecvList() { proto_cmd_client_t *protoCmd; char *line; @@ -226,23 +226,23 @@ static void eventClientWorkRecvList() #endif if (protoCmd != NULL) { protoCmd->fce_proto(line); - lastPingServerAlive = getMyTime(); + lastPingServerAlive = timer_get_current_time(); } } - destroyListItem(listRecvMsg, free); - listRecvMsg = newList(); + list_destroy_item(listRecvMsg, free); + listRecvMsg = list_new(); } static void eventPingServer() { my_time_t currentTime; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); if (currentTime - lastPing > CLIENT_TIMEOUT) { proto_send_ping_client(); - lastPing = getMyTime(); + lastPing = timer_get_current_time(); } } @@ -250,7 +250,7 @@ static bool_t isServerAlive() { my_time_t currentTime; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); if (currentTime - lastPingServerAlive > SERVER_TIMEOUT_ALIVE) { return FALSE; @@ -294,7 +294,7 @@ static void selectClientSocket() select(max_fd + 1, &readfds, (fd_set *) NULL, (fd_set *) NULL, &tv); if (FD_ISSET(sock, &readfds)) { - if (eventServerSelect() > 0) { + if (server_eventSelect() > 0) { isNext = TRUE; } } @@ -308,7 +308,7 @@ static void eventTraffic() { my_time_t currentTime; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); if (currentTime - lastTraffic > 5000) { lastTraffic = currentTime; @@ -322,7 +322,7 @@ static void eventTraffic() #endif -void eventClient() +void client_event() { #ifdef SUPPORT_TRAFFIC eventTraffic(); @@ -330,27 +330,27 @@ void eventClient() eventPingServer(); selectClientSocket(); - eventClientWorkRecvList(); + client_eventWorkRecvList(); } static void quitUdpClient() { assert(sock_server_udp != NULL); - closeUdpSocket(sock_server_udp); + sock_udp_close(sock_server_udp); DEBUG_MSG(_("Closing UDP connection.\n")); } -void quitClient() +void client_quit() { proto_send_end_client(); assert(listRecvMsg != NULL); - destroyListItem(listRecvMsg, free); - destroyBuffer(clientRecvBuffer); - destroyBuffer(clientSendBuffer); + list_destroy_item(listRecvMsg, free); + buffer_destroy(clientRecvBuffer); + buffer_destroy(clientSendBuffer); if (sock_server_udp != NULL) { quitUdpClient(); diff --git a/src/client/client.h b/src/client/client.h index 8ff0d3d..55c95b5 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -11,9 +11,9 @@ # define CLIENT_BUFFER_LIMIT 4096 -extern int initClient(char *ip, int port); -extern void sendServer(char *msg); -extern void eventClient(); -extern void quitClient(); +extern int client_init(char *ip, int port); +extern void client_send(char *msg); +extern void client_event(); +extern void client_quit(); #endif diff --git a/src/client/configFile.c b/src/client/configFile.c index 74509fe..162658b 100644 --- a/src/client/configFile.c +++ b/src/client/configFile.c @@ -120,8 +120,8 @@ int setValueInConfigFile(textFile_t * textFile, char *env, char *val) ret = setValue(line, env, val); if (ret != NULL) { - delListItem(textFile->text, i, free); - insList(textFile->text, i, ret); + list_del_item(textFile->text, i, free); + list_ins(textFile->text, i, ret); return 0; } @@ -139,7 +139,7 @@ void loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int le char line[STR_SIZE]; sprintf(line, "%s=\"%s\"", env, butVal); - addList(textFile->text, strdup(line)); + list_add(textFile->text, strdup(line)); DEBUG_MSG(_("ADDING: \"%s\" into config file.\n"), line); } diff --git a/src/client/font.c b/src/client/font.c index c701e3f..731e86d 100644 --- a/src/client/font.c +++ b/src/client/font.c @@ -10,19 +10,19 @@ static int fontSize; static bool_t isFontInit = FALSE; -bool_t isFontInicialized() +bool_t font_is_inicialized() { return isFontInit; } -void initFont() +void font_init() { char *arg[] = {":lang=he:outline=true:style=Book", "family", "style", "weight", "file", NULL}; char *font_file; font_config_t *font_list; int res; - assert(isInterfaceInicialized() == TRUE); + assert(interface_is_inicialized() == TRUE); res = fontconfig_init(); @@ -69,7 +69,7 @@ void initFont() /* * Zobrazi text *string na suradnicu x y s farbou RGB */ -void drawFont(char *string, int x, int y, int r, int g, int b) +void font_draw(char *string, int x, int y, int r, int g, int b) { SDL_Surface *text; image_t *image; @@ -83,13 +83,13 @@ void drawFont(char *string, int x, int y, int r, int g, int b) // because if string=="" TTF_RenderUTF8_Blended returns NULL if( text != NULL ){ - image = newImage(text); - drawImage(image, x, y, 0, 0, image->w, image->h); - destroyImage(image); + image = image_new(text); + image_draw(image, x, y, 0, 0, image->w, image->h); + image_destroy(image); }; } -void drawFontMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b) +void font_drawMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b) { SDL_Rect src_rect, dst_rect; SDL_Surface *text; @@ -121,22 +121,22 @@ void drawFontMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b) dst_rect.x = x; dst_rect.y = y; - i = newImage(text); + i = image_new(text); //posibly broken - drawImage(i, x, y, 0, 0, my_w, my_h); - destroyImage(i); + image_draw(i, x, y, 0, 0, my_w, my_h); + image_destroy(i); } /* * Vrati velkost daneho fontu. */ -int getFontSize() +int font_get_size() { return fontSize; } -void getTextSize(char *s, int *w, int *h) +void font_text_size(char *s, int *w, int *h) { assert(s != NULL); assert(w != NULL); @@ -148,7 +148,7 @@ void getTextSize(char *s, int *w, int *h) /* * Uvolni font z pamete. */ -void quitFont() +void font_quit() { TTF_CloseFont(g_font); TTF_Quit(); diff --git a/src/client/font.h b/src/client/font.h index 6f30a71..17aa76e 100644 --- a/src/client/font.h +++ b/src/client/font.h @@ -17,13 +17,13 @@ # define COLOR_YELLOW 255, 255, 0 # define FONT_SIZE 16 -extern bool_t isFontInicialized(); -extern void initFont(); -extern void drawFont(char *s, int x, int y, int r, int g, int b); -extern void drawFontMaxSize(char *s, int x, int y, int w, int h, int r, int g, +extern bool_t font_is_inicialized(); +extern void font_init(); +extern void font_draw(char *s, int x, int y, int r, int g, int b); +extern void font_drawMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b); -extern int getFontSize(); -extern void getTextSize(char *s, int *w, int *h); -extern void quitFont(); +extern int font_get_size(); +extern void font_text_size(char *s, int *w, int *h); +extern void font_quit(); #endif diff --git a/src/client/game.c b/src/client/game.c index 310c45a..310f1cb 100644 --- a/src/client/game.c +++ b/src/client/game.c @@ -44,66 +44,66 @@ static void initGame() { - createHomeDirector(); + homeDirector_create(); - initSDL(); - initFont(); - initLayer(); - initImageData(); + interface_init(); + font_init(); + layer_init(); + image_init(); #ifndef NO_SOUND - initAudio(); - initSound(); - initMusic(); + audio_init(); + sound_init(); + music_init(); #endif - initScreen(); - initArenaFile(); - initTux(); - initItem(); - initShot(); - initPanel(); - initWorld(); - - initScreenMainMenu(); - initScreenAnalyze(); - initScreenChoiceArena(); - initScreenSetting(); - initScreenSettingKeys(); - initScreenGameType(); - initScreenDownArena(); - initScreenCredits(); - initScreenTable(); - initScreenBrowser(); + screen_init(); + arenaFile_init(); + tux_init(); + item_init(); + shot_init(); + panel_init(); + word_init(); + + mainMenu_init(); + analyze_init(); + choiceArena_init(); + setting_init(); + settingKey_int(); + gameType_init(); + downArena_init(); + scredits_init(); + table_init(); + browser_init(); } -void quitGame() +void game_quit() { - quitSDL(); - - quitScreenMainMenu(); - quitScreenAnalyze(); - quitScreenSetting(); - quitScreenSettingKeys(); - quitScreenGameType(); - quitScreenDownArena(); - quitScreenChoiceArena(); - quitScreenCredits(); - quitScreenTable(); - quitScreenBrowser(); - - quitLayer(); - quitFont(); - quitScreen(); - quitArenaFile(); - quitItem(); - quitTux(); - quitShot(); - quitPanel(); - quitWorld(); - quitImageData(); + interface_quit(); + + mainMenu_quit(); + analyze_quit(); + setting_quit(); + settingKey_quit(); + gameType_quit(); + downArena_quit(); + choiceArena_quit(); + scredits_quit(); + table_quit(); + browser_quit(); + + layer_quit(); + font_quit(); + screen_quit(); + arenaFile_quit(); + item_quiy(); + tux_quit(); + shot_quit(); + panel_quit(); + word_quit(); + image_quit(); #ifndef NO_SOUND - quitSound(); - quitMusic(); - quitAudio(); + sound_quit(); + music_quit(); + audio_quit(); #endif DEBUG_MSG(_("Quitting TUXANCI...\n")); @@ -111,12 +111,12 @@ void quitGame() exit(0); } -void startGame() +void game_start() { initGame(); - startScreen("mainMenu"); + screen_start("mainMenu"); - eventSDL(); - quitGame(); + interface_event(); + game_quit(); } diff --git a/src/client/game.h b/src/client/game.h index 981e975..8591fca 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -3,7 +3,7 @@ # define GAME_H -extern void quitGame(); -extern void startGame(); +extern void game_quit(); +extern void game_start(); #endif diff --git a/src/client/hotKey.c b/src/client/hotKey.c index 228e50d..bf8cc96 100644 --- a/src/client/hotKey.c +++ b/src/client/hotKey.c @@ -53,13 +53,13 @@ static hotKey_t *findHotkey(SDLKey key) return NULL; } -void initHotKey() +void hotKey_init() { - listHotKey = newList(); - lastActive = getMyTime(); + listHotKey = list_new(); + lastActive = timer_get_current_time(); } -void registerHotKey(SDLKey key, void (*handler) ()) +void hotKey_register(SDLKey key, void (*handler) ()) { hotKey_t *hotkey; /* @@ -68,10 +68,10 @@ void registerHotKey(SDLKey key, void (*handler) ()) } */ hotkey = newHotKey(key, handler); - insList(listHotKey, 0, hotkey); + list_ins(listHotKey, 0, hotkey); } -void unregisterHotKey(SDLKey key) +void unhotKey_register(SDLKey key) { hotKey_t *hotkey; int my_index; @@ -82,12 +82,12 @@ void unregisterHotKey(SDLKey key) assert(!"This hotkey not register"); } - my_index = searchListItem(listHotKey, hotkey); + my_index = list_search(listHotKey, hotkey); assert(my_index != -1); - delListItem(listHotKey, my_index, destroyHotKey); + list_del_item(listHotKey, my_index, destroyHotKey); } -void enableHotKey(SDLKey key) +void hotKey_enable(SDLKey key) { hotKey_t *hotkey; @@ -97,11 +97,11 @@ void enableHotKey(SDLKey key) assert(!"This hotkey not register"); } - lastActive = getMyTime(); + lastActive = timer_get_current_time(); hotkey->active = TRUE; } -void disableHotKey(SDLKey key) +void hotKey_disable(SDLKey key) { hotKey_t *hotkey; @@ -111,17 +111,17 @@ void disableHotKey(SDLKey key) assert(!"This hotkey not register"); } - lastActive = getMyTime(); + lastActive = timer_get_current_time(); hotkey->active = FALSE; } -void eventHotKey() +void hotKey_event() { my_time_t currentTime; Uint8 *mapa; int i; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); if (currentTime - lastActive < HOTKEY_ACTIVE_INTERVAL) { return; @@ -135,7 +135,7 @@ void eventHotKey() this = (hotKey_t *) listHotKey->list[i]; if (mapa[this->key] == SDL_PRESSED && this->active == TRUE) { - lastActive = getMyTime(); + lastActive = timer_get_current_time(); //printf("hotKey = %d\n", this->key); this->handler(); @@ -144,7 +144,7 @@ void eventHotKey() } } -void quitHotKey() +void hotKey_quit() { - destroyListItem(listHotKey, destroyHotKey); + list_destroy_item(listHotKey, destroyHotKey); } diff --git a/src/client/hotKey.h b/src/client/hotKey.h index 1cdf647..33b1491 100644 --- a/src/client/hotKey.h +++ b/src/client/hotKey.h @@ -5,12 +5,12 @@ # define HOTKEY_ACTIVE_INTERVAL 500 -extern void initHotKey(); -extern void registerHotKey(SDLKey key, void (*handler) ()); -extern void unregisterHotKey(SDLKey key); -extern void enableHotKey(SDLKey key); -extern void disableHotKey(SDLKey key); -extern void eventHotKey(); -extern void quitHotKey(); +extern void hotKey_init(); +extern void hotKey_register(SDLKey key, void (*handler) ()); +extern void unhotKey_register(SDLKey key); +extern void hotKey_enable(SDLKey key); +extern void hotKey_disable(SDLKey key); +extern void hotKey_event(); +extern void hotKey_quit(); #endif diff --git a/src/client/image.c b/src/client/image.c index 711d8b4..bbff3cb 100644 --- a/src/client/image.c +++ b/src/client/image.c @@ -14,7 +14,7 @@ static list_t *listStorage; static bool_t isImageDataInit = FALSE; -bool_t isImageInicialized() +bool_t image_is_inicialized() { return isImageDataInit; } @@ -22,13 +22,13 @@ bool_t isImageInicialized() /* * Inicializuje globalny zoznam obrazkov */ -void initImageData() +void image_init() { - assert(isInterfaceInicialized() == TRUE); + assert(interface_is_inicialized() == TRUE); DEBUG_MSG(_("Initializing image database\n")); - listStorage = newStorage(); + listStorage = storage_new(); isImageDataInit = TRUE; } @@ -65,7 +65,7 @@ static SDL_Surface *loadImage(const char *filename, int alpha) #ifndef SUPPORT_OPENGL -image_t *newImage(SDL_Surface * surface) +image_t *image_new(SDL_Surface * surface) { image_t *new; @@ -96,11 +96,11 @@ unsigned int closestpoweroftwo(unsigned int i) } /* convert from SDL_Surface to image_t - * WARNING: newImage is indestructive to surface, caller is responsible for freeing surface - * surface is not needed for image_t after execution of newImage + * WARNING: image_new is indestructive to surface, caller is responsible for freeing surface + * surface is not needed for image_t after execution of image_new */ -image_t* newImage(SDL_Surface *surface) +image_t* image_new(SDL_Surface *surface) { image_t *new; Uint32 rmask, gmask, bmask, amask; @@ -151,7 +151,7 @@ image_t* newImage(SDL_Surface *surface) } #endif -void destroyImage(image_t * p) +void image_destroy(image_t * p) { assert(p != NULL); @@ -172,7 +172,7 @@ void destroyImage(image_t * p) * *name - nazov obrazku ( pouzije sa ako vyhadavaci retazec v zazanem ) * alpha - 0 - nema alpha kanal | 1 - ma alpha kanal */ -image_t *addImageData(char *file, int alpha, char *name, char *group) +image_t *image_add(char *file, int alpha, char *name, char *group) { SDL_Surface *surface; image_t *new; @@ -182,9 +182,9 @@ image_t *addImageData(char *file, int alpha, char *name, char *group) assert(group != NULL); surface = loadImage(file, alpha); - new = newImage(surface); + new = image_new(surface); - addItemToStorage(listStorage, group, name, new); + storage_add(listStorage, group, name, new); DEBUG_MSG(_("Loading image %s\n"), file); @@ -195,37 +195,37 @@ image_t *addImageData(char *file, int alpha, char *name, char *group) * Vrati odkaz na image_data v globalnom zozname obrazkov * a nazvom *s */ -image_t *getImage(char *group, char *name) +image_t *image_get(char *group, char *name) { assert(group != NULL); assert(name != NULL); - return getItemFromStorage(listStorage, group, name); + return storage_get(listStorage, group, name); } -void delImage(char *group, char *name) +void image_del(char *group, char *name) { assert(group != NULL); assert(name != NULL); - delItemFromStorage(listStorage, group, name, destroyImage); + storage_del(listStorage, group, name, image_destroy); } -void delAllImageInGroup(char *group) +void image_del_all_image_in_group(char *group) { assert(group != NULL); - delAllItemFromStorage(listStorage, group, destroyImage); + storage_del_all(listStorage, group, image_destroy); } #ifndef SUPPORT_OPENGL -void drawImage(image_t * p, int x, int y, int px, int py, int w, int h) +void image_draw(image_t * p, int x, int y, int px, int py, int w, int h) { static SDL_Surface *screen = NULL; SDL_Rect dst_rect, src_rect; if (screen == NULL) { - screen = getSDL_Screen(); + screen = interface_get_screen(); } dst_rect.x = x; @@ -244,7 +244,7 @@ void drawImage(image_t * p, int x, int y, int px, int py, int w, int h) /* * Draws image on screen at [x,y], with width w and height h, top-left corner on image is at [px,py] */ -void drawImage(image_t *image, int x,int y, int px, int py, int w, int h) +void image_draw(image_t *image, int x,int y, int px, int py, int w, int h) { /* x -coordinate of left border xx- coordinate of right border, * y -coordinate of top border yy- coordinate of bottom border, @@ -291,10 +291,10 @@ void drawImage(image_t *image, int x,int y, int px, int py, int w, int h) /* * Odstrani zoznam obrazkov z pamate */ -void quitImageData() +void image_quit() { DEBUG_MSG(_("Quitting image database\n")); - destroyStorage(listStorage, destroyImage); + storage_destroy(listStorage, image_destroy); isImageDataInit = FALSE; } diff --git a/src/client/image.h b/src/client/image.h index 03e952d..b6347db 100644 --- a/src/client/image.h +++ b/src/client/image.h @@ -46,15 +46,15 @@ typedef struct image_struct } image_t; #endif -extern bool_t isImageInicialized(); -extern void initImageData(); -extern image_t* newImage(SDL_Surface *surface); -extern void destroyImage(image_t * p); -extern image_t *addImageData(char *file, int alpha, char *name, char *group); -extern image_t *getImage(char *group, char *name); -extern void delImage(char *group, char *name); -extern void delAllImageInGroup(char *group); -extern void drawImage(image_t * p, int x, int y, int px, int py, int w, int h); -extern void quitImageData(); +extern bool_t image_is_inicialized(); +extern void image_init(); +extern image_t* image_new(SDL_Surface *surface); +extern void image_destroy(image_t * p); +extern image_t *image_add(char *file, int alpha, char *name, char *group); +extern image_t *image_get(char *group, char *name); +extern void image_del(char *group, char *name); +extern void image_del_all_image_in_group(char *group); +extern void image_draw(image_t * p, int x, int y, int px, int py, int w, int h); +extern void image_quit(); #endif diff --git a/src/client/interface.c b/src/client/interface.c index fba9521..ec87e4f 100644 --- a/src/client/interface.c +++ b/src/client/interface.c @@ -30,7 +30,7 @@ static bool_t isInterfaceInit = FALSE; // flag, kterym se ridi zarazovani klaves do bufferu static bool_t keyboardBufferEnabled = FALSE; -bool_t isInterfaceInicialized() +bool_t interface_is_inicialized() { return isInterfaceInit; } @@ -48,12 +48,12 @@ static Uint32 TimerCallback(Uint32 interval, void *param) return interval; } -void enableKeyboardBuffer() +void interface_enable_keyboard_buffer() { keyboardBufferEnabled = TRUE; } -void disableKeyboardBuffer() +void interface_disable_keyboard_buffer() { keyboardBufferEnabled = FALSE; } @@ -117,7 +117,7 @@ SDL_Surface * SetVideoMode(int width, int height, int bpp, Uint32 flags) } #endif -int initSDL() +int interface_init() { #ifdef DEBUG DEBUG_MSG(_("Initializing SDL system\n")); @@ -151,10 +151,10 @@ int initSDL() SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL); - initKeyboardBuffer(KEYBOARD_BUFFER_SIZE); + keyboardBuffer_init(KEYBOARD_BUFFER_SIZE); - initHotKey(); - registerHotKey(SDLK_F1, hotkey_screen); + hotKey_init(); + hotKey_register(SDLK_F1, hotkey_screen); srand((unsigned) time(NULL)); isInterfaceInit = TRUE; @@ -162,13 +162,13 @@ int initSDL() return 0; } -SDL_Surface *getSDL_Screen() +SDL_Surface *interface_get_screen() { //return my_surface; return screen; } -void interfaceRefresh() +void interface_refresh() { #ifndef SUPPORT_OPENGL SDL_Flip(screen); @@ -179,17 +179,17 @@ void interfaceRefresh() #endif } -void getMousePosition(int *x, int *y) +void interface_get_mouse_position(int *x, int *y) { SDL_GetMouseState(x, y); } -int isMouseClicked() +int interface_is_mouse_clicket() { return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT); } -int isPressAnyKey() +int interface_is_press_any_key() { Uint8 *mapa; int i; @@ -224,7 +224,7 @@ int hack_slow() static bool_t isSlowHack = FALSE; time_t currentTime; - currentTime = getMyTime(); + currentTime = timer_get_current_time(); if( lastTime == 0 ) { @@ -238,7 +238,7 @@ int hack_slow() { //printf("start slow hack (%d)\n", currentTime - lastTime); isSlowHack = TRUE; - lastTime = getMyTime(); + lastTime = timer_get_current_time(); return 1; } @@ -246,7 +246,7 @@ int hack_slow() { //printf("stop slow hack (%d)\n", currentTime - lastTime); isSlowHack = FALSE; - lastTime = getMyTime(); + lastTime = timer_get_current_time(); return 0; } @@ -255,7 +255,7 @@ int hack_slow() //printf("hack time interval %d\n", currentTime - lastTime); } - lastTime = getMyTime(); + lastTime = timer_get_current_time(); return isSlowHack; } @@ -272,7 +272,7 @@ int eventAction() default: //neni potreba vyuzivat frontu stale if (keyboardBufferEnabled == TRUE) - pushKeyToKeyboardBuffer(event.key.keysym); + keyboardBuffer_push(event.key.keysym); break; } break; @@ -285,10 +285,10 @@ int eventAction() break; } - drawScreen(); - eventScreen(); - eventHotKey(); - switchScreen(); + screen_draw(); + screen_event(); + hotKey_event(); + screen_switch(); break; default: @@ -323,7 +323,7 @@ int eventAction() return 0; } -void eventSDL() +void interface_event() { while (1) { if (eventAction() == -1) @@ -331,12 +331,12 @@ void eventSDL() } } -void quitSDL() +void interface_quit() { DEBUG_MSG(_("Quitting SDL\n")); - quitHotKey(); - quitKeyboardBuffer(); + hotKey_quit(); + keyboardBuffer_quit(); SDL_Quit(); diff --git a/src/client/interface.h b/src/client/interface.h index 3dbe5f3..d6b2715 100644 --- a/src/client/interface.h +++ b/src/client/interface.h @@ -33,16 +33,16 @@ // velikost klavesoveho bufferu (ve znacich) # define KEYBOARD_BUFFER_SIZE 256 -extern bool_t isInterfaceInicialized(); -extern void enableKeyboardBuffer(); -extern void disableKeyboardBuffer(); -extern int initSDL(); -extern SDL_Surface *getSDL_Screen(); -extern void getMousePosition(int *x, int *y); -extern int isMouseClicked(); -extern int isPressAnyKey(); -extern void interfaceRefresh(); -extern void eventSDL(); -extern void quitSDL(); +extern bool_t interface_is_inicialized(); +extern void interface_enable_keyboard_buffer(); +extern void interface_disable_keyboard_buffer(); +extern int interface_init(); +extern SDL_Surface *interface_get_screen(); +extern void interface_get_mouse_position(int *x, int *y); +extern int interface_is_mouse_clicket(); +extern int interface_is_press_any_key(); +extern void interface_refresh(); +extern void interface_event(); +extern void interface_quit(); #endif diff --git a/src/client/keyboardBuffer.c b/src/client/keyboardBuffer.c index 0454bdb..aff7b67 100644 --- a/src/client/keyboardBuffer.c +++ b/src/client/keyboardBuffer.c @@ -23,7 +23,7 @@ static SDL_keysym emptyKey; /* * Key buffer initializes. The parameter sets the number of keys. */ -void initKeyboardBuffer(int size) +void keyboardBuffer_init(int size) { assert(size > 0); assert(keyboardBuffer == NULL); @@ -47,7 +47,7 @@ void initKeyboardBuffer(int size) /* * Empty the buffer */ -void clearKeyboardBuffer() +void keyboardBuffer_clear() { assert(keyboardBuffer != NULL); @@ -61,7 +61,7 @@ void clearKeyboardBuffer() * Adds key to the end of the buffer. If the buffer is overrun, * an error is printed to stderr and the key is dropped. */ -bool_t pushKeyToKeyboardBuffer(SDL_keysym key) +bool_t keyboardBuffer_push(SDL_keysym key) { assert(keyboardBuffer != NULL); @@ -86,7 +86,7 @@ bool_t pushKeyToKeyboardBuffer(SDL_keysym key) * Takes out first key from the buffer and returns it. If the buffer is empty, * an error is printed to stderr and SDLK_UNKNOWN is returned. */ -SDL_keysym popKeyFromKeyboardBuffer() +SDL_keysym keyboardBuffer_pop() { assert(keyboardBuffer != NULL); @@ -112,7 +112,7 @@ SDL_keysym popKeyFromKeyboardBuffer() /* * The buffer size */ -int getKeyboardBufferSize() +int keyboardBuffer_get_size() { assert(keyboardBuffer != NULL); return keyboardBuffer->size; @@ -121,23 +121,23 @@ int getKeyboardBufferSize() /* * Number of keys in the buffer */ -int KeyboardBufferCount() +int keyboardBuffer_get_count() { assert(keyboardBuffer != NULL); return keyboardBuffer->count; } -bool_t isAnyKeyInKeyboardBuffer() +bool_t keyboardBuffer_is_any_key() { - return KeyboardBufferCount() > 0 ? TRUE : FALSE; + return keyboardBuffer_get_count() > 0 ? TRUE : FALSE; } /* * Frees the buffer. If it is not empty, information * about filling is prined to stderr first. */ -void quitKeyboardBuffer() +void keyboardBuffer_quit() { assert(keyboardBuffer != NULL); diff --git a/src/client/keyboardBuffer.h b/src/client/keyboardBuffer.h index c3c40af..eb4f307 100644 --- a/src/client/keyboardBuffer.h +++ b/src/client/keyboardBuffer.h @@ -22,13 +22,13 @@ typedef struct { int end; /* ukazatel na konec bufferu (tj. odkud se odebiraji klavesy) */ } keyboardBuffer_t; -extern void initKeyboardBuffer(int size); -extern void clearKeyboardBuffer(); -extern bool_t pushKeyToKeyboardBuffer(SDL_keysym key); -extern SDL_keysym popKeyFromKeyboardBuffer(); -extern int getKeyboardBufferSize(); -extern int KeyboardBufferCount(); -extern bool_t isAnyKeyInKeyboardBuffer(); -extern void quitKeyboardBuffer(); +extern void keyboardBuffer_init(int size); +extern void keyboardBuffer_clear(); +extern bool_t keyboardBuffer_push(SDL_keysym key); +extern SDL_keysym keyboardBuffer_pop(); +extern int keyboardBuffer_get_size(); +extern int keyboardBuffer_get_count(); +extern bool_t keyboardBuffer_is_any_key(); +extern void keyboardBuffer_quit(); #endif /* KEYBOARDBUFFER_H_ */ diff --git a/src/client/layer.c b/src/client/layer.c index 2bf8cde..4ec1a30 100644 --- a/src/client/layer.c +++ b/src/client/layer.c @@ -16,7 +16,7 @@ static list_t *listLayer; static bool_t isLayerInit = FALSE; -bool_t isLayerInicialized() +bool_t layer_is_inicialized() { return isLayerInit; } @@ -24,9 +24,9 @@ bool_t isLayerInicialized() /* * Initializes global list of the layers */ -void initLayer() +void layer_init() { - listLayer = newList(); + listLayer = list_new(); isLayerInit = TRUE; } @@ -63,24 +63,24 @@ void addLayer(image_t * img, int x, int y, int px, int py, int w, int h, int pla // here we are sure, that we want to insert it somewhere else than the begining for (i = 0; i < listLayer->count; i++) { - actual = getList(listLayer, i); + actual = list_get(listLayer, i); actual_value = actual->layer*WINDOW_SIZE_Y + actual->y + actual->h; if (actual_value > new_value) { - insList(listLayer, i, new); + list_ins(listLayer, i, new); return; }; }; - addList(listLayer, new); + list_add(listLayer, new); } /* * Draws all items onto the screen according to the layer and coordinate Y+H * After drawing frees the list */ -void drawLayer() +void layer_draw_all() { layer_t *this; int i; @@ -88,23 +88,23 @@ void drawLayer() for (i = 0; i < listLayer->count; i++) { this = (layer_t *) listLayer->list[i]; - drawImage(this->image, this->x, this->y, this->px, this->py, this->w, this->h); + image_draw(this->image, this->x, this->y, this->px, this->py, this->w, this->h); } //printf("listLayer->count = %d\n", listLayer->count); - destroyListItem(listLayer, free); - listLayer = newList(); + list_destroy_item(listLayer, free); + listLayer = list_new(); } -void drawLayerCenter(int x, int y) +void layer_draw_center(int x, int y) { layer_t *this; int screen_x, screen_y; int i; //int count = 0; - getCenterScreen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y); + arena_get_center_screen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y); for (i = 0; i < listLayer->count; i++) { this = (layer_t *) listLayer->list[i]; @@ -117,7 +117,7 @@ void drawLayerCenter(int x, int y) } //count++; - drawImage(this->image, this->x - screen_x, this->y - screen_y, + image_draw(this->image, this->x - screen_x, this->y - screen_y, this->px, this->py, this->w, this->h); //printf("%d %d\n", this->x - screen_x, this->y - screen_y); @@ -125,11 +125,11 @@ void drawLayerCenter(int x, int y) //printf("count = %d\n", count); - destroyListItem(listLayer, free); - listLayer = newList(); + list_destroy_item(listLayer, free); + listLayer = list_new(); } -void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h) +void layer_draw_slpit(int local_x, int local_y, int x, int y, int w, int h) { layer_t *this; int i; @@ -173,7 +173,7 @@ void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h) this->h -= (local_y + (this->y - y) + this->h) - (local_y + h); } - drawImage(this->image, local_x + (this->x - x), local_y + (this->y - y), + image_draw(this->image, local_x + (this->x - x), local_y + (this->y - y), this->px, this->py, this->w, this->h); //printf("%d %d\n", this->x - screen_x, this->y - screen_y); @@ -181,21 +181,21 @@ void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h) //printf("count = %d\n", count); - destroyListItem(listLayer, free); - listLayer = newList(); + list_destroy_item(listLayer, free); + listLayer = list_new(); } -void flushLayer() +void layer_flush() { - destroyListItem(listLayer, free); - listLayer = newList(); + list_destroy_item(listLayer, free); + listLayer = list_new(); } /* * Delete list of layers from memory */ -void quitLayer() +void layer_quit() { - destroyListItem(listLayer, free); + list_destroy_item(listLayer, free); isLayerInit = FALSE; } diff --git a/src/client/layer.h b/src/client/layer.h index 37c0628..66a0580 100644 --- a/src/client/layer.h +++ b/src/client/layer.h @@ -24,8 +24,8 @@ typedef struct layer_str { image_t *image; //dane surfrace } layer_t; -extern bool_t isLayerInicialized(); -extern void initLayer(); +extern bool_t layer_is_inicialized(); +extern void layer_init(); /* * Add image to queue for rendering @@ -43,11 +43,11 @@ extern void addLayer(image_t * img, /* * Draws queue on the screen */ -extern void drawLayer(); -extern void drawLayerCenter(int x, int y); -extern void drawLayerSplit(int local_x, int local_y, int x, int y, int w, +extern void layer_draw_all(); +extern void layer_draw_center(int x, int y); +extern void layer_draw_slpit(int local_x, int local_y, int x, int y, int w, int h); -extern void flushLayer(); -extern void quitLayer(); +extern void layer_flush(); +extern void layer_quit(); #endif diff --git a/src/client/panel.c b/src/client/panel.c index b7d0360..1d7846a 100644 --- a/src/client/panel.c +++ b/src/client/panel.c @@ -19,32 +19,32 @@ static image_t *g_bonus; static bool_t isPanelInit = FALSE; -bool_t isPanelInicialized() +bool_t panel_is_inicialized() { return isPanelInit; } -void initPanel() +void panel_init() { - assert(isImageInicialized() == TRUE); - assert(isInterfaceInicialized() == TRUE); - - g_panel = addImageData("panel.png", IMAGE_ALPHA, "panel", IMAGE_GROUP_BASE); - g_shot = addImageData("panel_shot.png", IMAGE_ALPHA, "panel_image_shot",IMAGE_GROUP_BASE); - g_bonus = addImageData("graf.bonus.png", IMAGE_ALPHA, "panel_graf_bonus", IMAGE_GROUP_BASE); - g_icon[GUN_SIMPLE] = addImageData("icon.gun.simple.png", IMAGE_ALPHA, "panel_gun", IMAGE_GROUP_BASE); - g_icon[GUN_DUAL_SIMPLE] = addImageData("icon.gun.dual.simple.png", IMAGE_ALPHA, "panel_dual", IMAGE_GROUP_BASE); - g_icon[GUN_TOMMY] = addImageData("icon.gun.tommy.png", IMAGE_ALPHA, "panel_tommy", IMAGE_GROUP_BASE); - g_icon[GUN_SCATTER] = addImageData("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter", IMAGE_GROUP_BASE); - g_icon[GUN_LASSER] = addImageData("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser", IMAGE_GROUP_BASE); - g_icon[GUN_MINE] = addImageData("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine", IMAGE_GROUP_BASE); - g_icon[GUN_BOMBBALL] = addImageData("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball", IMAGE_GROUP_BASE); - g_icon[BONUS_SPEED] = addImageData("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed", IMAGE_GROUP_BASE); - g_icon[BONUS_SHOT] = addImageData("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot", IMAGE_GROUP_BASE); - g_icon[BONUS_TELEPORT] = addImageData("icon.bonus.teleport.png", IMAGE_ALPHA, "panel_teleport", IMAGE_GROUP_BASE); - g_icon[BONUS_GHOST] = addImageData("icon.bonus.ghost.png", IMAGE_ALPHA, "panel_ghost", IMAGE_GROUP_BASE); - g_icon[BONUS_4X] = addImageData("icon.bonus.4x.png", IMAGE_ALPHA, "panel_4x", IMAGE_GROUP_BASE); - g_icon[BONUS_HIDDEN] = addImageData("icon.bonus.hidden.png", IMAGE_ALPHA, "panel_hidden", IMAGE_GROUP_BASE); + assert(image_is_inicialized() == TRUE); + assert(interface_is_inicialized() == TRUE); + + g_panel = image_add("panel.png", IMAGE_ALPHA, "panel", IMAGE_GROUP_BASE); + g_shot = image_add("panel_shot.png", IMAGE_ALPHA, "panel_image_shot",IMAGE_GROUP_BASE); + g_bonus = image_add("graf.bonus.png", IMAGE_ALPHA, "panel_graf_bonus", IMAGE_GROUP_BASE); + g_icon[GUN_SIMPLE] = image_add("icon.gun.simple.png", IMAGE_ALPHA, "panel_gun", IMAGE_GROUP_BASE); + g_icon[GUN_DUAL_SIMPLE] = image_add("icon.gun.dual.simple.png", IMAGE_ALPHA, "panel_dual", IMAGE_GROUP_BASE); + g_icon[GUN_TOMMY] = image_add("icon.gun.tommy.png", IMAGE_ALPHA, "panel_tommy", IMAGE_GROUP_BASE); + g_icon[GUN_SCATTER] = image_add("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter", IMAGE_GROUP_BASE); + g_icon[GUN_LASSER] = image_add("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser", IMAGE_GROUP_BASE); + g_icon[GUN_MINE] = image_add("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine", IMAGE_GROUP_BASE); + g_icon[GUN_BOMBBALL] = image_add("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball", IMAGE_GROUP_BASE); + g_icon[BONUS_SPEED] = image_add("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed", IMAGE_GROUP_BASE); + g_icon[BONUS_SHOT] = image_add("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot", IMAGE_GROUP_BASE); + g_icon[BONUS_TELEPORT] = image_add("icon.bonus.teleport.png", IMAGE_ALPHA, "panel_teleport", IMAGE_GROUP_BASE); + g_icon[BONUS_GHOST] = image_add("icon.bonus.ghost.png", IMAGE_ALPHA, "panel_ghost", IMAGE_GROUP_BASE); + g_icon[BONUS_4X] = image_add("icon.bonus.4x.png", IMAGE_ALPHA, "panel_4x", IMAGE_GROUP_BASE); + g_icon[BONUS_HIDDEN] = image_add("icon.bonus.hidden.png", IMAGE_ALPHA, "panel_hidden", IMAGE_GROUP_BASE); isPanelInit = TRUE; } @@ -62,22 +62,22 @@ static void drawScore(tux_t * tux_right, tux_t * tux_left) sprintf(strScoreLine, "%d", tux_left->score); } - getTextSize(strScoreLine, &w, &h); - drawFont(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y, COLOR_WHITE); + font_text_size(strScoreLine, &w, &h); + font_draw(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y, COLOR_WHITE); } -static void drawShot(int n, int x, int y) +static void shot_draw(int n, int x, int y) { - drawImage(g_shot, x, y, n * PANEL_SHOT_WIDTH, 0, PANEL_SHOT_WIDTH, PANEL_SHOT_HEIGHT); + image_draw(g_shot, x, y, n * PANEL_SHOT_WIDTH, 0, PANEL_SHOT_WIDTH, PANEL_SHOT_HEIGHT); } -static void drawShotInfo(tux_t * tux, int x, int y) +static void shot_drawInfo(tux_t * tux, int x, int y) { int i; if (tux->pickup_time > 0) { for (i = 0; i < tux->pickup_time / 3; i++) { - drawShot(PANEL_SHOT_LINE, x + i * PANEL_SHOT_WIDTH, y); + shot_draw(PANEL_SHOT_LINE, x + i * PANEL_SHOT_WIDTH, y); } return; @@ -85,21 +85,21 @@ static void drawShotInfo(tux_t * tux, int x, int y) for (i = 0; i < GUN_MAX_SHOT; i++) { if (tux->shot[tux->gun] > i) { - drawShot(PANEL_SHOT_FILL, x + i * (PANEL_SHOT_WIDTH + 2), y); + shot_draw(PANEL_SHOT_FILL, x + i * (PANEL_SHOT_WIDTH + 2), y); } else { - drawShot(PANEL_SHOT_EMPTY, x + i * (PANEL_SHOT_WIDTH + 2), y); + shot_draw(PANEL_SHOT_EMPTY, x + i * (PANEL_SHOT_WIDTH + 2), y); } } } static void drawGunInfo(tux_t * tux, int x, int y) { - drawImage(g_icon[tux->gun], x, y, 0, 0, g_icon[tux->gun]->w, g_icon[tux->gun]->h); + image_draw(g_icon[tux->gun], x, y, 0, 0, g_icon[tux->gun]->w, g_icon[tux->gun]->h); } static void drawBonusInfo(tux_t * tux, int x, int y) { - drawImage(g_icon[tux->bonus], x, y, 0, 0, g_icon[tux->bonus]->w, g_icon[tux->bonus]->h); + image_draw(g_icon[tux->bonus], x, y, 0, 0, g_icon[tux->bonus]->w, g_icon[tux->bonus]->h); } static void drawGrafBonus(tux_t * tux, int x, int y) @@ -107,17 +107,17 @@ static void drawGrafBonus(tux_t * tux, int x, int y) int offset; offset = tux->bonus_time / 5; - drawImage(g_bonus, x, y, 0, 0, g_bonus->w, g_bonus->h / 2); - drawImage(g_bonus, x + 1, y, 0, g_bonus->h / 2, offset, g_bonus->h / 2); + image_draw(g_bonus, x, y, 0, 0, g_bonus->w, g_bonus->h / 2); + image_draw(g_bonus, x + 1, y, 0, g_bonus->h / 2, offset, g_bonus->h / 2); } -static void drawTuxRight(tux_t * tux) +static void tux_drawRight(tux_t * tux) { if (tux == NULL) { return; } - drawShotInfo(tux, PANEL_LOCATION_X + 740, PANEL_LOCATION_Y + 34); + shot_drawInfo(tux, PANEL_LOCATION_X + 740, PANEL_LOCATION_Y + 34); drawGunInfo(tux, PANEL_LOCATION_X + 620, PANEL_LOCATION_Y + 30); if (tux->bonus != BONUS_NONE) { @@ -126,13 +126,13 @@ static void drawTuxRight(tux_t * tux) } } -static void drawTuxLeft(tux_t * tux) +static void tux_drawLeft(tux_t * tux) { if (tux == NULL) { return; } - drawShotInfo(tux, PANEL_LOCATION_X + 8, PANEL_LOCATION_Y + 34); + shot_drawInfo(tux, PANEL_LOCATION_X + 8, PANEL_LOCATION_Y + 34); drawGunInfo(tux, PANEL_LOCATION_X + 130, PANEL_LOCATION_Y + 30); if (tux->bonus != BONUS_NONE) { @@ -141,20 +141,20 @@ static void drawTuxLeft(tux_t * tux) } } -void drawPanel(tux_t * tux_right, tux_t * tux_left) +void panel_draw(tux_t * tux_right, tux_t * tux_left) { - drawImage(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w, g_panel->h); + image_draw(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w, g_panel->h); drawScore(tux_right, tux_left); - if (isRecivedNewMsg()) { - drawFont("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE); + if (chat_is_recived_new_msg()) { + font_draw("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE); } - drawTuxRight(tux_right); - drawTuxLeft(tux_left); + tux_drawRight(tux_right); + tux_drawLeft(tux_left); } -void quitPanel() +void panel_quit() { isPanelInit = FALSE; } diff --git a/src/client/panel.h b/src/client/panel.h index 6478f3b..94a55e0 100644 --- a/src/client/panel.h +++ b/src/client/panel.h @@ -19,9 +19,9 @@ # define PANEL_SHOT_EMPTY 1 # define PANEL_SHOT_LINE 2 -extern bool_t isPanelInicialized(); -extern void initPanel(); -extern void drawPanel(tux_t * tux_right, tux_t * tux_left); -extern void quitPanel(); +extern bool_t panel_is_inicialized(); +extern void panel_init(); +extern void panel_draw(tux_t * tux_right, tux_t * tux_left); +extern void panel_quit(); #endif diff --git a/src/client/pauza.c b/src/client/pauza.c index eb346dc..ae125d2 100644 --- a/src/client/pauza.c +++ b/src/client/pauza.c @@ -29,34 +29,34 @@ static void hotkey_pauze() switchPauzed(); } -void initPauza() +void pauza_init() { - g_pauza = addImageData("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER); + g_pauza = image_add("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER); activePauza = FALSE; - registerHotKey(SDLK_p, hotkey_pauze); + hotKey_register(SDLK_p, hotkey_pauze); } -void drawPauza() +void pauza_draw() { if (activePauza) { - drawImage(g_pauza, + image_draw(g_pauza, WINDOW_SIZE_X / 2 - g_pauza->w / 2, WINDOW_SIZE_Y / 2 - g_pauza->h / 2, 0, 0, g_pauza->w, g_pauza->h); } } -void eventPauza() +void pauza_event() { } -bool_t isPauzeActive() +bool_t pauza_is_active() { return activePauza; } -void quitPauza() +void pauza_quit() { - unregisterHotKey(SDLK_p); + unhotKey_register(SDLK_p); } diff --git a/src/client/pauza.h b/src/client/pauza.h index 8ddd1f8..2743af4 100644 --- a/src/client/pauza.h +++ b/src/client/pauza.h @@ -7,10 +7,10 @@ # include "main.h" -extern void initPauza(); -extern void drawPauza(); -extern void eventPauza(); -extern bool_t isPauzeActive(); -extern void quitPauza(); +extern void pauza_init(); +extern void pauza_draw(); +extern void pauza_event(); +extern bool_t pauza_is_active(); +extern void pauza_quit(); #endif diff --git a/src/client/radar.c b/src/client/radar.c index b45d80f..5770cf0 100644 --- a/src/client/radar.c +++ b/src/client/radar.c @@ -40,7 +40,7 @@ static void destroyRadarItem(radar_item_t * p) free(p); } -void addToRadar(int id, int x, int y, int type) +void radar_add(int id, int x, int y, int type) { int i; @@ -57,10 +57,10 @@ void addToRadar(int id, int x, int y, int type) } } - addList(listRadar, newRadarItem(id, x, y, type)); + list_add(listRadar, newRadarItem(id, x, y, type)); } -void delFromRadar(int id) +void radar_del(int id) { int i; @@ -70,26 +70,26 @@ void delFromRadar(int id) thisRadarItem = (radar_item_t *) listRadar->list[i]; if (thisRadarItem->id == id) { - delListItem(listRadar, i, destroyRadarItem); + list_del_item(listRadar, i, destroyRadarItem); return; } } } -void initRadar() +void radar_init() { - assert(isImageInicialized() == TRUE); - assert(isInterfaceInicialized() == TRUE); + assert(image_is_inicialized() == TRUE); + assert(interface_is_inicialized() == TRUE); - g_radar = addImageData("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER); - listRadar = newList(); + g_radar = image_add("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER); + listRadar = list_new(); } -void drawRadar(arena_t * arena) +void radar_draw(arena_t * arena) { int i; - drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0, RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2); + image_draw(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0, RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2); for (i = 0; i < listRadar->count; i++) { radar_item_t *thisRadarItem; @@ -102,13 +102,13 @@ void drawRadar(arena_t * arena) y = (((float) RADAR_SIZE_Y) / ((float) arena->h)) * ((float) thisRadarItem->y); if (x >= 0 && x <= RADAR_SIZE_X && y >= 0 && y <= RADAR_SIZE_Y) { - drawImage(g_radar, RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y, + image_draw(g_radar, RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y, 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2); } } } -void quitRadar() +void radar_quit() { - destroyListItem(listRadar, destroyRadarItem); + list_destroy_item(listRadar, destroyRadarItem); } diff --git a/src/client/radar.h b/src/client/radar.h index 0092055..9f43968 100644 --- a/src/client/radar.h +++ b/src/client/radar.h @@ -15,10 +15,10 @@ # define RADAR_TYPE_TUX 1 # define RADAR_TYPE_ITEM 2 -extern void initRadar(); -extern void addToRadar(int id, int x, int y, int type); -extern void delFromRadar(int id); -extern void drawRadar(arena_t * arena); -extern void quitRadar(); +extern void radar_init(); +extern void radar_add(int id, int x, int y, int type); +extern void radar_del(int id); +extern void radar_draw(arena_t * arena); +extern void radar_quit(); #endif diff --git a/src/client/saveDialog.c b/src/client/saveDialog.c index 1c832e7..0ae3554 100644 --- a/src/client/saveDialog.c +++ b/src/client/saveDialog.c @@ -46,7 +46,7 @@ static void eventWidget(void *p) button = (widget_t *) p; if (button == widgetButtonSave) { - saveArena(getTextFromWidgetTextfield(widgetTextFieldName), getCurrentArena()); + save_arena(textField_get_text(widgetTextFieldName), arena_get_current()); switchTerm(); } @@ -60,45 +60,45 @@ static void hotkey_saveDialog() switchTerm(); } -void initSaveDialog() +void saveDialog_init() { activeSaveDialog = FALSE; - g_background = getImage(IMAGE_GROUP_BASE, "screen_main"); + g_background = image_get(IMAGE_GROUP_BASE, "screen_main"); - widgetLabelMsg = newWidgetLabel("name", SAVE_DIALOG_LOCATIN_X + 20, + widgetLabelMsg = label_new("name", SAVE_DIALOG_LOCATIN_X + 20, SAVE_DIALOG_LOCATIN_Y + 20, WIDGET_LABEL_LEFT); - widgetTextFieldName = newWidgetTextfield("noname", WIDGET_TEXTFIELD_FILTER_ALPHANUM, + widgetTextFieldName = textField_new("noname", WIDGET_TEXTFIELD_FILTER_ALPHANUM, widgetLabelMsg->x + widgetLabelMsg->w + 10, widgetLabelMsg->y); - widgetButtonSave = newWidgetButton("Save", SAVE_DIALOG_LOCATIN_X + 20, + widgetButtonSave = button_new("Save", SAVE_DIALOG_LOCATIN_X + 20, SAVE_DIALOG_LOCATIN_Y + 60, eventWidget); - widgetButtonBack = newWidgetButton("Back", SAVE_DIALOG_LOCATIN_X + 20 + + widgetButtonBack = button_new("Back", SAVE_DIALOG_LOCATIN_X + 20 + WIDGET_BUTTON_WIDTH + 20, SAVE_DIALOG_LOCATIN_Y + 60, eventWidget); - registerHotKey(SDLK_F2, hotkey_saveDialog); + hotKey_register(SDLK_F2, hotkey_saveDialog); } -bool_t isSaveDialogActive() +bool_t saveDialog_is_active() { return activeSaveDialog; } -void drawSaveDialog() +void saveDialog_draw() { if (activeSaveDialog == FALSE) { return; } - drawImage(g_background, + image_draw(g_background, SAVE_DIALOG_LOCATIN_X, SAVE_DIALOG_LOCATIN_Y, SAVE_DIALOG_LOCATIN_X, @@ -106,30 +106,30 @@ void drawSaveDialog() SAVE_DIALOG_SIZE_X, SAVE_DIALOG_SIZE_Y); - drawWidgetLabel(widgetLabelMsg); - drawWidgetTextfield(widgetTextFieldName); - drawWidgetButton(widgetButtonSave); - drawWidgetButton(widgetButtonBack); + label_draw(widgetLabelMsg); + textField_draw(widgetTextFieldName); + button_draw(widgetButtonSave); + button_draw(widgetButtonBack); } -void eventSaveDialog() +void saveDialog_event() { if (activeSaveDialog == FALSE) { return; } - eventWidgetTextfield(widgetTextFieldName); - eventWidgetButton(widgetButtonSave); - eventWidgetButton(widgetButtonBack); + textField_event(widgetTextFieldName); + button_event(widgetButtonSave); + button_event(widgetButtonBack); } -void quitSaveDialog() +void saveDialog_quit() { - unregisterHotKey(SDLK_F2); + unhotKey_register(SDLK_F2); - destroyWidgetLabel(widgetLabelMsg); - destroyWidgetTextfield(widgetTextFieldName); - destroyWidgetButton(widgetButtonSave); - destroyWidgetButton(widgetButtonBack); + label_destroy(widgetLabelMsg); + textField_destroy(widgetTextFieldName); + button_destroy(widgetButtonSave); + button_destroy(widgetButtonBack); } diff --git a/src/client/saveDialog.h b/src/client/saveDialog.h index d96a252..a126955 100644 --- a/src/client/saveDialog.h +++ b/src/client/saveDialog.h @@ -12,10 +12,10 @@ # define SAVE_DIALOG_LOCATIN_Y (WINDOW_SIZE_Y/2 - SAVE_DIALOG_SIZE_Y/2) -extern void initSaveDialog(); -extern bool_t isSaveDialogActive(); -extern void drawSaveDialog(); -extern void eventSaveDialog(); -extern void quitSaveDialog(); +extern void saveDialog_init(); +extern bool_t saveDialog_is_active(); +extern void saveDialog_draw(); +extern void saveDialog_event(); +extern void saveDialog_quit(); #endif diff --git a/src/client/saveLoad.c b/src/client/saveLoad.c index 0448a4f..cd1b94a 100644 --- a/src/client/saveLoad.c +++ b/src/client/saveLoad.c @@ -32,7 +32,7 @@ static void action_saveTux(space_t * space, tux_t * tux, textFile_t * textFile) tux->shot[GUN_LASSER], tux->shot[GUN_MINE], tux->shot[GUN_BOMBBALL], tux->bonus_time, tux->pickup_time); - addList(textFile->text, strdup(str)); + list_add(textFile->text, strdup(str)); } static void @@ -45,7 +45,7 @@ action_saveShot(space_t * space, shot_t * shot, textFile_t * textFile) shot->position, shot->gun, shot->author_id, shot->isCanKillAuthor); - addList(textFile->text, strdup(str)); + list_add(textFile->text, strdup(str)); } static void @@ -57,7 +57,7 @@ action_saveItem(space_t * space, item_t * item, textFile_t * textFile) item->id, item->type, item->x, item->y, item->count, item->frame, item->author_id); - addList(textFile->text, strdup(str)); + list_add(textFile->text, strdup(str)); } static void saveContextArenaToTextFile(textFile_t * textFile, arena_t * arena) @@ -65,37 +65,37 @@ static void saveContextArenaToTextFile(textFile_t * textFile, arena_t * arena) char str[STR_PROTO_SIZE]; sprintf(str, "ARENA %s %d %d", - getArenaNetName(getChoiceArena()), + arenaFile_get_net_name(choiceArena_get()), arena->countRound, arena->max_countRound); - addList(textFile->text, strdup(str)); + list_add(textFile->text, strdup(str)); - actionSpace(arena->spaceTux, action_saveTux, textFile); - actionSpace(arena->spaceShot, action_saveShot, textFile); - actionSpace(arena->spaceItem, action_saveItem, textFile); + space_action(arena->spaceTux, action_saveTux, textFile); + space_action(arena->spaceShot, action_saveShot, textFile); + space_action(arena->spaceItem, action_saveItem, textFile); } -void saveArena(char *filename, arena_t * arena) +void save_arena(char *filename, arena_t * arena) { textFile_t *textFile; char path[STR_PATH_SIZE]; - sprintf(path, "%s/%s.sav", getHomeDirector(), filename); + sprintf(path, "%s/%s.sav", homeDirector_get(), filename); DEBUG_MSG(_("Saving game to: \"%s\"\n"), path); - textFile = newTextFile(path); + textFile = textFile_new(path); if (textFile != NULL) { saveContextArenaToTextFile(textFile, arena); - saveTextFile(textFile); - destroyTextFile(textFile); + textFile_save(textFile); + textFile_destroy(textFile); } else { fprintf(stderr, _("I was unable to save: \"%s\"\n"), path); } } -static arena_t *loadArenaFromLine(char *line) +static arena_t *load_arenaFromLine(char *line) { char cmd[STR_SIZE]; char name[STR_SIZE]; @@ -105,9 +105,9 @@ static arena_t *loadArenaFromLine(char *line) sscanf(line, "%s %s %d %d", cmd, name, &countRound, &max_countRound); - setWorldArena(getArenaFileFormNetName(name)); + word_set_arena(arenaFile_get_file_format_net_name(name)); - arena = getCurrentArena(); + arena = arena_get_current(); arena->max_countRound = max_countRound; arena->countRound = countRound; @@ -130,26 +130,26 @@ static void loadTuxFromLine(char *line, arena_t * arena) name, &myGun, &myBonus, &gun1, &gun2, &gun3, &gun4, &gun5, &gun6, &gun7, &time1, &time2); - tux = newTux(); - replaceTuxID(tux, id); - addObjectToSpace(arena->spaceTux, tux); + tux = tux_new(); + tux_replace_id(tux, id); + space_add(arena->spaceTux, tux); tux->control = control; if (tux->control == TUX_CONTROL_KEYBOARD_RIGHT) { - setControlTux(tux, TUX_CONTROL_KEYBOARD_RIGHT); + word_set_control_tux(tux, TUX_CONTROL_KEYBOARD_RIGHT); } if (tux->control == TUX_CONTROL_KEYBOARD_LEFT) { - setControlTux(tux, TUX_CONTROL_KEYBOARD_LEFT); + word_set_control_tux(tux, TUX_CONTROL_KEYBOARD_LEFT); } if (tux->control == TUX_CONTROL_AI) { - loadModule("libmodAI"); - setControlTux(tux, TUX_CONTROL_KEYBOARD_LEFT); + module_load("libmodAI"); + word_set_control_tux(tux, TUX_CONTROL_KEYBOARD_LEFT); } - moveObjectInSpace(arena->spaceTux, tux, x, y); + space_move_object(arena->spaceTux, tux, x, y); tux->status = status; tux->position = position; tux->frame = frame; @@ -178,17 +178,17 @@ static void loadShotFromLine(char *line, arena_t * arena) cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id, &isCanKillAuthor); - shot = newShot(x, y, px, py, gun, author_id); + shot = shot_new(x, y, px, py, gun, author_id); - replaceShotID(shot, shot_id); + shot_replace_id(shot, shot_id); shot->isCanKillAuthor = isCanKillAuthor; shot->position = position; if (shot->gun == GUN_LASSER) { - transformOnlyLasser(shot); + shot_transform_lasser(shot); } - addObjectToSpace(arena->spaceShot, shot); + space_add(arena->spaceShot, shot); } static void loadItemFromLine(char *line, arena_t * arena) @@ -200,13 +200,13 @@ static void loadItemFromLine(char *line, arena_t * arena) sscanf(line, "%s %d %d %d %d %d %d %d %d", cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id); - item = newItem(x, y, type, author_id); + item = item_new(x, y, type, author_id); - replaceItemID(item, id); + item_replace_id(item, id); item->count = count; item->frame = frame; - addObjectToSpace(arena->spaceItem, item); + space_add(arena->spaceItem, item); } static arena_t *loadContextArenaFromTextFile(textFile_t * textFile) @@ -222,7 +222,7 @@ static arena_t *loadContextArenaFromTextFile(textFile_t * textFile) line = (char *) textFile->text->list[i]; if (strncmp(line, "ARENA", 5) == 0) { - arena = loadArenaFromLine(line); + arena = load_arenaFromLine(line); } if (strncmp(line, "TUX", 3) == 0) { @@ -241,20 +241,20 @@ static arena_t *loadContextArenaFromTextFile(textFile_t * textFile) return arena; } -void loadArena(char *filename) +void load_arena(char *filename) { textFile_t *textFile; char path[STR_PATH_SIZE]; - sprintf(path, "%s/%s", getHomeDirector(), filename); + sprintf(path, "%s/%s", homeDirector_get(), filename); DEBUG_MSG(_("Loadig game from file: \"%s\"\n"), path); - textFile = loadTextFile(path); + textFile = textFile_load(path); if (textFile != NULL) { loadContextArenaFromTextFile(textFile); - destroyTextFile(textFile); + textFile_destroy(textFile); } else { fprintf(stderr, _("Unable to load save: \"%s\"\n"), path); } diff --git a/src/client/saveLoad.h b/src/client/saveLoad.h index f62e293..f405f6b 100644 --- a/src/client/saveLoad.h +++ b/src/client/saveLoad.h @@ -6,7 +6,7 @@ # include "textFile.h" # include "arena.h" -extern void saveArena(char *filename, arena_t * arena); -extern void loadArena(char *filename); +extern void save_arena(char *filename, arena_t * arena); +extern void load_arena(char *filename); #endif diff --git a/src/client/screen.c b/src/client/screen.c index 71d48d8..d4b7289 100644 --- a/src/client/screen.c +++ b/src/client/screen.c @@ -19,12 +19,12 @@ static list_t *listScreen; static bool_t isScreenInit = FALSE; -bool_t isScreenInicialized() +bool_t screen_is_inicialized() { return isScreenInit; } -screen_t *newScreen(char *name, void (*fce_start) (), void (*fce_event) (), +screen_t *screen_new(char *name, void (*fce_start) (), void (*fce_event) (), void (*fce_draw) (), void (*fce_stop) ()) { screen_t *new; @@ -45,7 +45,7 @@ screen_t *newScreen(char *name, void (*fce_start) (), void (*fce_event) (), return new; } -void destroyScreen(screen_t * p) +void screen_destroy(screen_t * p) { assert(p != NULL); @@ -53,18 +53,18 @@ void destroyScreen(screen_t * p) free(p); } -void registerScreen(screen_t * p) +void screen_register(screen_t * p) { assert(p != NULL); DEBUG_MSG(_("Registering screen: \"%s\"\n"), p->name); - addList(listScreen, p); + list_add(listScreen, p); } -void initScreen() +void screen_init() { - listScreen = newList(); + listScreen = list_new(); currentScreen = NULL; futureScreen = NULL; @@ -89,19 +89,19 @@ static screen_t *findScreen(char *name) return NULL; } -void setScreen(char *name) +void screen_set(char *name) { futureScreen = findScreen(name); assert(futureScreen != NULL); } -void switchScreen() +void screen_switch() { if (futureScreen == NULL) { return; } - flushLayer(); + layer_flush(); if (currentScreen != NULL) { DEBUG_MSG(_("Stopping screen: \"%s\"\n"), currentScreen->name); @@ -118,19 +118,19 @@ void switchScreen() currentScreen->fce_start(); } -void startScreen(char *name) +void screen_start(char *name) { - setScreen(name); - switchScreen(); + screen_set(name); + screen_switch(); } -char *getScreen() +char *screen_get() { assert(currentScreen != NULL); return currentScreen->name; } -void drawScreen() +void screen_draw() { static int count = 0; @@ -144,21 +144,21 @@ void drawScreen() #ifdef DEBUG_TIME_DRAW my_time_t prev; - prev = getMyTimeMicro(); + prev = timer_get_current_timeMicro(); #endif currentScreen->fce_draw(); - interfaceRefresh(); + interface_refresh(); #ifdef DEBUG_TIME_DRAW - printf("c draw time = %d\n", getMyTimeMicro() - prev); + printf("c draw time = %d\n", timer_get_current_timeMicro() - prev); #endif } } -void eventScreen() +void screen_event() { assert(currentScreen != NULL); #if 0 @@ -166,23 +166,23 @@ void eventScreen() if( last == 0 ) { - last = getMyTime(); + last = timer_get_current_time(); } - printf("%d\n", getMyTime()-last); - last = getMyTime(); + printf("%d\n", timer_get_current_time()-last); + last = timer_get_current_time(); #endif currentScreen->fce_event(); #ifdef DEBUG_TIME_EVENT - printf("c event time = %d\n", getMyTimeMicro() - prev); + printf("c event time = %d\n", timer_get_current_timeMicro() - prev); #endif } -void quitScreen() +void screen_quit() { assert(listScreen != NULL); - destroyListItem(listScreen, destroyScreen); + list_destroy_item(listScreen, screen_destroy); isScreenInit = FALSE; } diff --git a/src/client/screen.h b/src/client/screen.h index 3227bfe..227696f 100644 --- a/src/client/screen.h +++ b/src/client/screen.h @@ -13,21 +13,21 @@ typedef struct screen_struct { void (*fce_stop) (); } screen_t; -extern bool_t isScreenInicialized(); +extern bool_t screen_is_inicialized(); -extern screen_t *newScreen(char *name, +extern screen_t *screen_new(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 void switchScreen(); -extern void startScreen(char *name); -extern char *getScreen(); -extern void drawScreen(); -extern void eventScreen(); -extern void quitScreen(); +extern void screen_destroy(screen_t * p); +extern void screen_register(screen_t * p); +extern void screen_init(); +extern void screen_set(char *name); +extern void screen_switch(); +extern void screen_start(char *name); +extern char *screen_get(); +extern void screen_draw(); +extern void screen_event(); +extern void screen_quit(); #endif diff --git a/src/client/term.c b/src/client/term.c index 4a1991c..7cfb346 100644 --- a/src/client/term.c +++ b/src/client/term.c @@ -18,12 +18,12 @@ static bool_t activeTerm; static my_time_t lastActive; static my_time_t lastRefresh; -void initTerm() +void term_init() { - listText = newList(); + listText = list_new(); activeTerm = FALSE; - lastActive = getMyTime(); + lastActive = timer_get_current_time(); lastRefresh = lastActive; } @@ -87,24 +87,24 @@ static void action_refreshTerm(space_t * space, tux_t * tux, void *p) getStrGun(tux->gun), tux->shot[tux->gun], getStrBonus(tux->bonus) ); - addList(listText, strdup(str)); + list_add(listText, strdup(str)); } static void refreshTerm() { arena_t *arena; - arena = getCurrentArena(); + arena = arena_get_current(); - destroyListItem(listText, free); - listText = newList(); + list_destroy_item(listText, free); + listText = list_new(); - actionSpace(arena->spaceTux, action_refreshTerm, NULL); + space_action(arena->spaceTux, action_refreshTerm, NULL); //printf("refresh term..\n"); } -void drawTerm() +void term_draw() { int i; @@ -116,7 +116,7 @@ void drawTerm() char *line; line = (char *) listText->list[i]; - drawFont(line, 10, 10 + i * 20, COLOR_WHITE); + font_draw(line, 10, 10 + i * 20, COLOR_WHITE); } } @@ -129,14 +129,14 @@ static void switchTerm() } } -void eventTerm() +void term_event() { my_time_t currentTime; Uint8 *mapa; mapa = SDL_GetKeyState(NULL); - currentTime = getMyTime(); + currentTime = timer_get_current_time(); if (currentTime - lastRefresh > TERM_REFRESH_TIME_INTERVAL) { lastRefresh = currentTime; @@ -151,8 +151,8 @@ void eventTerm() } } -void quitTerm() +void term_quit() { assert(listText != NULL); - destroyListItem(listText, free); + list_destroy_item(listText, free); } diff --git a/src/client/term.h b/src/client/term.h index ffc0e14..445edbd 100644 --- a/src/client/term.h +++ b/src/client/term.h @@ -8,9 +8,9 @@ # define TERM_ACTIVE_TIME_INTERVAL 500 # define TERM_REFRESH_TIME_INTERVAL 1000 -extern void initTerm(); -extern void drawTerm(); -extern void eventTerm(); -extern void quitTerm(); +extern void term_init(); +extern void term_draw(); +extern void term_event(); +extern void term_quit(); #endif diff --git a/src/modules/modAI.c b/src/modules/modAI.c index a6fa311..e8b5172 100644 --- a/src/modules/modAI.c +++ b/src/modules/modAI.c @@ -67,20 +67,20 @@ void forkAlternative(list_t * list, alternative_t * p, int w, int h) switch (p->route) { case TUX_UP: - addList(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y)); - addList(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y)); + list_add(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y)); + list_add(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y)); break; case TUX_RIGHT: - addList(list, cloneAlternative(p, TUX_UP, x, y - (h + 5))); - addList(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5))); + list_add(list, cloneAlternative(p, TUX_UP, x, y - (h + 5))); + list_add(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5))); break; case TUX_LEFT: - addList(list, cloneAlternative(p, TUX_UP, x, y - (h + 5))); - addList(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5))); + list_add(list, cloneAlternative(p, TUX_UP, x, y - (h + 5))); + list_add(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5))); break; case TUX_DOWN: - addList(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y)); - addList(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y)); + list_add(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y)); + list_add(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y)); break; } @@ -138,10 +138,10 @@ tux_t *findOtherTux(space_t * space) { int i; - for (i = 0; i < getSpaceCount(space); i++) { + for (i = 0; i < space_get_count(space); i++) { tux_t *thisTux; - thisTux = getItemFromSpace(space, i); + thisTux = space_get_item(space, i); if (thisTux->control != TUX_CONTROL_AI) { return thisTux; @@ -158,31 +158,31 @@ static void shotTux(arena_t * arena, tux_t * tux_ai, tux_t * tux_rival) int x_rival, y_rival; int w, h; - export_fce->fce_getTuxProportion(tux_ai, &x_ai, &y_ai, &w, &h); - export_fce->fce_getTuxProportion(tux_rival, &x_rival, &y_rival, &w, &h); + export_fce->fce_tux_get_proportion(tux_ai, &x_ai, &y_ai, &w, &h); + export_fce->fce_tux_get_proportion(tux_rival, &x_rival, &y_rival, &w, &h); if (y_rival < y_ai && x_rival > x_ai && x_rival < x_ai + limit) { - export_fce->fce_actionTux(tux_ai, TUX_UP); - export_fce->fce_actionTux(tux_ai, TUX_SHOT); + export_fce->fce_tux_action(tux_ai, TUX_UP); + export_fce->fce_tux_action(tux_ai, TUX_SHOT); } if (x_rival > x_ai && y_rival > y_ai && y_rival < y_ai + limit) { - export_fce->fce_actionTux(tux_ai, TUX_RIGHT); - export_fce->fce_actionTux(tux_ai, TUX_SHOT); + export_fce->fce_tux_action(tux_ai, TUX_RIGHT); + export_fce->fce_tux_action(tux_ai, TUX_SHOT); } if (x_rival < x_ai && y_rival > y_ai && y_rival < y_ai + limit) { - export_fce->fce_actionTux(tux_ai, TUX_LEFT); - export_fce->fce_actionTux(tux_ai, TUX_SHOT); + export_fce->fce_tux_action(tux_ai, TUX_LEFT); + export_fce->fce_tux_action(tux_ai, TUX_SHOT); } if (y_rival > y_ai && x_rival > x_ai && x_rival < x_ai + limit) { - export_fce->fce_actionTux(tux_ai, TUX_DOWN); - export_fce->fce_actionTux(tux_ai, TUX_SHOT); + export_fce->fce_tux_action(tux_ai, TUX_DOWN); + export_fce->fce_tux_action(tux_ai, TUX_SHOT); } } -static void eventTuxAI(tux_t * tux) +static void tux_eventAI(tux_t * tux) { arena_t *arena; tux_t *rivalTux; @@ -200,10 +200,10 @@ static void eventTuxAI(tux_t * tux) int countLimit = 0; int countDo = 0; - export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h); + export_fce->fce_tux_get_proportion(tux, &x, &y, &w, &h); //printf("tux AI %d %d\n", x, y); - arena = export_fce->fce_getCurrentArena(); + arena = export_fce->fce_arena_get_current(); rivalTux = findOtherTux(arena->spaceTux); @@ -211,19 +211,19 @@ static void eventTuxAI(tux_t * tux) return; } - listAlternative = newList(); - listDst = newList(); - listFork = newList(); + listAlternative = list_new(); + listDst = list_new(); + listFork = list_new(); shotTux(arena, tux, rivalTux); - export_fce->fce_getTuxProportion(rivalTux, &rival_x, &rival_y, NULL, NULL); + export_fce->fce_tux_get_proportion(rivalTux, &rival_x, &rival_y, NULL, NULL); //printf("tux rival %d %d\n", rival_x, rival_y); - addList(listAlternative, newAlternative(TUX_UP, x, y - (h + 10))); - addList(listAlternative, newAlternative(TUX_RIGHT, x + (w + 10), y)); - addList(listAlternative, newAlternative(TUX_LEFT, x - (w + 10), y)); - addList(listAlternative, newAlternative(TUX_DOWN, x, y + (h + 10))); + list_add(listAlternative, newAlternative(TUX_UP, x, y - (h + 10))); + list_add(listAlternative, newAlternative(TUX_RIGHT, x + (w + 10), y)); + list_add(listAlternative, newAlternative(TUX_LEFT, x - (w + 10), y)); + list_add(listAlternative, newAlternative(TUX_DOWN, x, y + (h + 10))); my_index = -1; while (1) { @@ -237,10 +237,10 @@ static void eventTuxAI(tux_t * tux) //printf("listFork->count = %d\n", listFork->count); for (j = 0; j < listFork->count; j++) { - addList(listAlternative, listFork->list[j]); + list_add(listAlternative, listFork->list[j]); } - listDoEmpty(listFork); + list_do_empty(listFork); my_index = 0; } @@ -255,7 +255,7 @@ static void eventTuxAI(tux_t * tux) break; if (this->step > 100) { - delListItem(listAlternative, my_index, destroyAlternative); + list_del_item(listAlternative, my_index, destroyAlternative); countLimit++; my_index--; continue; @@ -263,27 +263,27 @@ static void eventTuxAI(tux_t * tux) moveAlternative(this, w * 2); - if (export_fce->fce_isFreeSpace(arena, this->x, this->y, w, h) == 1) { + if (export_fce->fce_arena__is_free_space(arena, this->x, this->y, w, h) == 1) { forkAlternative(listFork, this, 2 * w, 2 * h); countFork++; continue; } if (export_fce-> - fce_conflictSpace(this->x, this->y, w, h, rival_x, rival_y, w, + fce_arena_conflict_space(this->x, this->y, w, h, rival_x, rival_y, w, h)) { //printf("this->step = %d\n", this->step); - delList(listAlternative, my_index); - addList(listDst, this); + list_del(listAlternative, my_index); + list_add(listDst, this); my_index--; //continue; break; } - if (export_fce->fce_isFreeSpace(arena, this->x, this->y, w, h) == 0) { + if (export_fce->fce_arena__is_free_space(arena, this->x, this->y, w, h) == 0) { //forkAlternative(listFork, this, w*2, h*2); - delListItem(listAlternative, my_index, destroyAlternative); + list_del_item(listAlternative, my_index, destroyAlternative); my_index--; countDel++; @@ -309,12 +309,12 @@ static void eventTuxAI(tux_t * tux) } if (recRoute != 0) { - export_fce->fce_actionTux(tux, recRoute); + export_fce->fce_tux_action(tux, recRoute); } - destroyListItem(listFork, destroyAlternative); - destroyListItem(listAlternative, destroyAlternative); - destroyListItem(listDst, destroyAlternative); + list_destroy_item(listFork, destroyAlternative); + list_destroy_item(listAlternative, destroyAlternative); + list_destroy_item(listDst, destroyAlternative); /* printf("countFork = %d\n", countFork); printf("countDel = %d\n", countDel); @@ -326,7 +326,7 @@ static void eventTuxAI(tux_t * tux) static void action_tuxAI(space_t * space, tux_t * tux, void *p) { if (tux->control == TUX_CONTROL_AI && tux->status == TUX_STATUS_ALIVE) { - eventTuxAI(tux); + tux_eventAI(tux); } } @@ -339,19 +339,19 @@ int event() //int i; if (lastEvent == 0) { - lastEvent = export_fce->fce_getMyTime(); + lastEvent = export_fce->fce_timer_get_current_time(); } - curentTime = export_fce->fce_getMyTime(); + curentTime = export_fce->fce_timer_get_current_time(); if (curentTime - lastEvent < 25) { return 0; } - lastEvent = export_fce->fce_getMyTime(); + lastEvent = export_fce->fce_timer_get_current_time(); //printf("event AI\n"); - arena = export_fce->fce_getCurrentArena(); + arena = export_fce->fce_arena_get_current(); if (arena == NULL) { return 0; @@ -359,7 +359,7 @@ int event() countTuxAI = 0; - actionSpace(arena->spaceTux, action_tuxAI, NULL); + space_action(arena->spaceTux, action_tuxAI, NULL); /* for( i = 0 ; i < arena->spaceTux->list->count ; i++ ) { @@ -370,7 +370,7 @@ int event() if( thisTux->control == TUX_CONTROL_AI && thisTux->status == TUX_STATUS_ALIVE ) { - eventTux(thisTux); + tux_event(thisTux); countTuxAI = 0; } } diff --git a/src/modules/modMove.c b/src/modules/modMove.c index 5059d73..deaf71e 100644 --- a/src/modules/modMove.c +++ b/src/modules/modMove.c @@ -29,7 +29,7 @@ static void move_tux(tux_t * tux, int x, int y, int w, int h) int dist_x = 0, dist_y = 0; // no warnning if (tux->bonus == BONUS_GHOST || - export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) + export_fce->fce_netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) return; switch (tux->position) { case TUX_UP: @@ -53,14 +53,14 @@ static void move_tux(tux_t * tux, int x, int y, int w, int h) break; } if (export_fce-> - fce_isFreeSpace(export_fce->fce_getCurrentArena(), dist_x, dist_y, + fce_arena__is_free_space(export_fce->fce_arena_get_current(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT)) { - moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceTux, tux, + space_move_object(export_fce->fce_arena_get_current()->spaceTux, tux, dist_x, dist_y); #ifndef PUBLIC_SERVER - //playSound("teleport", SOUND_GROUP_BASE); + //sound_play("teleport", SOUND_GROUP_BASE); #endif - if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (export_fce->fce_netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { char msg[STR_PROTO_SIZE]; sprintf(msg, "movetux %d %d %d", tux->id, dist_x, dist_y); if (tux->bonus == BONUS_HIDDEN) @@ -114,7 +114,7 @@ static void transformShot(shot_t * shot, int position) shot->isCanKillAuthor = TRUE; if (shot->gun == GUN_LASSER) - export_fce->fce_transformOnlyLasser(shot); + export_fce->fce_shot_transform_lasser(shot); } static void @@ -157,9 +157,9 @@ move_shot(shot_t * shot, int position, int src_x, int src_y, break; } - moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot, + space_move_object(export_fce->fce_arena_get_current()->spaceShot, shot, new_x, new_y); - if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (export_fce->fce_netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { char msg[STR_PROTO_SIZE]; sprintf(msg, "moveshot %d %d %d %d %d %d", @@ -172,8 +172,8 @@ move_shot(shot_t * shot, int position, int src_x, int src_y, int init(export_fce_t * p) { export_fce = p; - export_fce->fce_addToShareFce("move_tux", (void *) move_tux); - export_fce->fce_addToShareFce("move_shot", (void *) move_shot); + export_fce->fce_shareFunction_add("move_tux", (void *) move_tux); + export_fce->fce_shareFunction_add("move_shot", (void *) move_shot); return 0; } @@ -188,11 +188,11 @@ static void proto_movetux(char *msg) assert(msg != NULL); sscanf(msg, "%s %d %d %d", cmd, &id, &x, &y); - space = export_fce->fce_getCurrentArena()->spaceTux; - tux = getObjectFromSpaceWithID(space, id); + space = export_fce->fce_arena_get_current()->spaceTux; + tux = space_get_object_id(space, id); if (tux != NULL) - moveObjectInSpace(space, tux, x, y); + space_move_object(space, tux, x, y); } static void proto_moveshot(char *msg) @@ -207,19 +207,19 @@ static void proto_moveshot(char *msg) sscanf(msg, "%s %d %d %d %d %d %d", cmd, &shot_id, &x, &y, &px, &py, &position); - space = export_fce->fce_getCurrentArena()->spaceShot; + space = export_fce->fce_arena_get_current()->spaceShot; - if ((shot = getObjectFromSpaceWithID(space, shot_id)) == NULL) + if ((shot = space_get_object_id(space, shot_id)) == NULL) return; - moveObjectInSpace(space, shot, x, y); + space_move_object(space, shot, x, y); shot->isCanKillAuthor = 1; shot->position = position; shot->px = px; shot->py = py; if (shot->gun == GUN_LASSER) - export_fce->fce_transformOnlyLasser(shot); + export_fce->fce_shot_transform_lasser(shot); } #ifndef PUBLIC_SERVER @@ -247,7 +247,7 @@ void cmdArena(char *line) void recvMsg(char *msg) { - if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER) + if (export_fce->fce_netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) return; if (strncmp(msg, "movetux", 7) == 0) diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c index 5d1728f..455bdce 100644 --- a/src/modules/modPipe.c +++ b/src/modules/modPipe.c @@ -165,7 +165,7 @@ static void cmd_teleport(char *line) 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)); + export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); #endif #ifdef PUBLIC_SERVER @@ -177,19 +177,19 @@ static void cmd_teleport(char *line) if (spacePipe == NULL) { spacePipe = - newSpace(export_fce->fce_getCurrentArena()->w, - export_fce->fce_getCurrentArena()->h, 320, 240, + space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, 320, 240, getStatusPipe, setStatusPipe); } - addObjectToSpace(spacePipe, new); + space_add(spacePipe, new); } static void moveShotFromPipe(shot_t * shot, pipe_t * pipe) { pipe_t *distPipe; - distPipe = getObjectFromSpaceWithID(spacePipe, pipe->id_out); + distPipe = space_get_object_id(spacePipe, pipe->id_out); if (distPipe == NULL) { fprintf(stderr, "Pipe ID for pipe \"%d\" was not found\n", pipe->id); @@ -204,13 +204,13 @@ int init(export_fce_t * p) { export_fce = p; - listPipe = newList(); + listPipe = list_new(); - if (export_fce->fce_loadDepModule("libmodMove") != 0) { + if (export_fce->fce_module_load_dep("libmodMove") != 0) { return -1; } - if ((fce_move_shot = export_fce->fce_getShareFce("move_shot")) == NULL) { + if ((fce_move_shot = export_fce->fce_shareFunction_get("move_shot")) == NULL) { return -1; } @@ -230,8 +230,8 @@ int draw(int x, int y, int w, int h) return 0; } - actionSpaceFromLocation(spacePipe, action_drawpipe, NULL, x, y, w, h); - //printSpace(spacePipe); + space_action_from_location(spacePipe, action_drawpipe, NULL, x, y, w, h); + //space_print(spacePipe); return 0; } @@ -267,9 +267,9 @@ static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) arena_t *arena; tux_t *author; - arena = export_fce->fce_getCurrentArena(); + arena = export_fce->fce_arena_get_current(); - author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id); + author = space_get_object_id(arena->spaceTux, shot->author_id); if (author != NULL && author->bonus == BONUS_GHOST && author->bonus_time > 0) { @@ -277,14 +277,14 @@ static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) } if (negPosition(shot->position) == pipe->position && - export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT) { + export_fce->fce_netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { moveShotFromPipe(shot, pipe); } else { if (shot->gun == GUN_BOMBBALL && - export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT) { - export_fce->fce_boundBombBall(shot); + export_fce->fce_netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { + export_fce->fce_shot_bound_bombBall(shot); } else { - //delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot); + //space_del_with_item(arena->spaceShot, shot, export_fce->fce_shot_destroy); shot->del = TRUE; } } @@ -296,9 +296,9 @@ static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) arena_t *arena; tux_t *author; - arena = export_fce->fce_getCurrentArena(); + arena = export_fce->fce_arena_get_current(); - author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id); + author = space_get_object_id(arena->spaceTux, shot->author_id); if (author != NULL && author->bonus == BONUS_GHOST && author->bonus_time > 0) { @@ -309,7 +309,7 @@ static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) moveShotFromPipe(shot, pipe); } else { if (shot->gun == GUN_BOMBBALL) { - export_fce->fce_boundBombBall(shot); + export_fce->fce_shot_bound_bombBall(shot); } else { shot->del = TRUE; } @@ -319,15 +319,15 @@ static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) static void action_eventshot(space_t * space, shot_t * shot, space_t * p_spacePipe) { - actionSpaceFromLocation(p_spacePipe, action_eventpipe, shot, shot->x, + space_action_from_location(p_spacePipe, action_eventpipe, shot, shot->x, shot->y, shot->w, shot->h); if (shot->del == TRUE) { - if (getNetTypeGame() == NET_GAME_TYPE_SERVER) { + if (netMultiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { proto_send_del_server(PROTO_SEND_ALL, NULL, shot->id); } - delObjectFromSpaceWithObject(space, shot, export_fce->fce_destroyShot); + space_del_with_item(space, shot, export_fce->fce_shot_destroy); } } @@ -338,11 +338,11 @@ int event() } // na skusku - if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) { + if (export_fce->fce_netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { return 0; } - actionSpace(export_fce->fce_getCurrentArena()->spaceShot, + space_action(export_fce->fce_arena_get_current()->spaceShot, action_eventshot, spacePipe); return 0; @@ -354,7 +354,7 @@ int isConflict(int x, int y, int w, int h) return 0; } - return isConflictWithObjectFromSpace(spacePipe, x, y, w, h); + return space_is_conflict_with_object(spacePipe, x, y, w, h); } void cmdArena(char *line) @@ -370,8 +370,8 @@ void recvMsg(char *msg) int destroy() { - destroySpaceWithObject(spacePipe, destroyPipe); - destroyList(listPipe); + space_destroy_with_item(spacePipe, destroyPipe); + list_destroy(listPipe); return 0; } diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c index 8f74eca..b7079ee 100644 --- a/src/modules/modTeleport.c +++ b/src/modules/modTeleport.c @@ -148,7 +148,7 @@ static void cmd_teleport(char *line) 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)); + export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); #endif #ifdef PUBLIC_SERVER @@ -158,12 +158,12 @@ static void cmd_teleport(char *line) if (spaceTeleport == NULL) { spaceTeleport = - newSpace(export_fce->fce_getCurrentArena()->w, - export_fce->fce_getCurrentArena()->h, 320, 240, + space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, 320, 240, getStatusTeleport, setStatusTeleport); } - addObjectToSpace(spaceTeleport, new); + space_add(spaceTeleport, new); } static teleport_t *getRandomTeleportBut(space_t * space, teleport_t * teleport) @@ -171,10 +171,10 @@ static teleport_t *getRandomTeleportBut(space_t * space, teleport_t * teleport) int my_index; do { - my_index = random() % getSpaceCount(space); - } while (getItemFromSpace(space, my_index) == teleport); + my_index = random() % space_get_count(space); + } while (space_get_item(space, my_index) == teleport); - return (teleport_t *) getItemFromSpace(space, my_index); + return (teleport_t *) space_get_item(space, my_index); } static int getRandomPosition() @@ -204,7 +204,7 @@ static void teleportTux(tux_t * tux, teleport_t * teleport) teleport_t *distTeleport; if (tux->bonus == BONUS_GHOST || - export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) { + export_fce->fce_netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { return; } @@ -230,17 +230,17 @@ int init(export_fce_t * p) { export_fce = p; - listTeleport = newList(); + listTeleport = list_new(); - if (export_fce->fce_loadDepModule("libmodMove") != 0) { + if (export_fce->fce_module_load_dep("libmodMove") != 0) { return -1; } - if ((fce_move_tux = export_fce->fce_getShareFce("move_tux")) == NULL) { + if ((fce_move_tux = export_fce->fce_shareFunction_get("move_tux")) == NULL) { return -1; } - if ((fce_move_shot = export_fce->fce_getShareFce("move_shot")) == NULL) { + if ((fce_move_shot = export_fce->fce_shareFunction_get("move_shot")) == NULL) { return -1; } @@ -261,7 +261,7 @@ int draw(int x, int y, int w, int h) return 0; } - actionSpaceFromLocation(spaceTeleport, action_drawteleport, NULL, x, y, w, + space_action_from_location(spaceTeleport, action_drawteleport, NULL, x, y, w, h); return 0; @@ -274,9 +274,9 @@ action_eventteleportshot(space_t * space, teleport_t * teleport, shot_t * shot) arena_t *arena; tux_t *author; - arena = export_fce->fce_getCurrentArena(); + arena = export_fce->fce_arena_get_current(); - author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id); + author = space_get_object_id(arena->spaceTux, shot->author_id); if (author != NULL && author->bonus == BONUS_GHOST && author->bonus_time > 0) { @@ -289,7 +289,7 @@ action_eventteleportshot(space_t * space, teleport_t * teleport, shot_t * shot) static void action_eventshot(space_t * space, shot_t * shot, space_t * p_spaceTeleport) { - actionSpaceFromLocation(p_spaceTeleport, action_eventteleportshot, shot, + space_action_from_location(p_spaceTeleport, action_eventteleportshot, shot, shot->x, shot->y, shot->w, shot->h); } @@ -304,9 +304,9 @@ action_eventtux(space_t * space, tux_t * tux, space_t * p_spaceTeleport) { int x, y, w, h; - export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h); + export_fce->fce_tux_get_proportion(tux, &x, &y, &w, &h); - actionSpaceFromLocation(p_spaceTeleport, action_eventteleporttux, tux, x, y, + space_action_from_location(p_spaceTeleport, action_eventteleporttux, tux, x, y, w, h); } @@ -316,13 +316,13 @@ int event() return 0; } - if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) { + if (export_fce->fce_netMultiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { return 0; } - actionSpace(export_fce->fce_getCurrentArena()->spaceShot, + space_action(export_fce->fce_arena_get_current()->spaceShot, action_eventshot, spaceTeleport); - actionSpace(export_fce->fce_getCurrentArena()->spaceTux, action_eventtux, + space_action(export_fce->fce_arena_get_current()->spaceTux, action_eventtux, spaceTeleport); return 0; @@ -349,7 +349,7 @@ void recvMsg(char *msg) int destroy() { - destroySpaceWithObject(spaceTeleport, destroyTeleport); - destroyList(listTeleport); + space_destroy_with_item(spaceTeleport, destroyTeleport); + list_destroy(listTeleport); return 0; } diff --git a/src/modules/modWall.c b/src/modules/modWall.c index d3734d5..b6fb54e 100644 --- a/src/modules/modWall.c +++ b/src/modules/modWall.c @@ -213,7 +213,7 @@ static void cmd_wall(char *line) #ifndef PUBLIC_SERVER new = newWall(x, y, w, h, img_x, img_y, layer, - export_fce->fce_getImage(IMAGE_GROUP_USER, str_image)); + export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); #endif #ifdef PUBLIC_SERVER @@ -222,29 +222,29 @@ static void cmd_wall(char *line) if (spaceWall == NULL) { spaceWall = - newSpace(export_fce->fce_getCurrentArena()->w, - export_fce->fce_getCurrentArena()->h, 320, 240, + space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, 320, 240, getStatusWall, setStatusWall); #ifndef PUBLIC_SERVER spaceImgWall = - newSpace(export_fce->fce_getCurrentArena()->w, - export_fce->fce_getCurrentArena()->h, 320, 240, + space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, 320, 240, getStatusImgWall, setStatusImgWall); #endif } - addObjectToSpace(spaceWall, new); + space_add(spaceWall, new); #ifndef PUBLIC_SERVER - addObjectToSpace(spaceImgWall, new); + space_add(spaceImgWall, new); #endif } int init(export_fce_t * p) { export_fce = p; - listWall = newList(); + listWall = list_new(); return 0; } @@ -262,9 +262,9 @@ int draw(int x, int y, int w, int h) return 0; } - actionSpaceFromLocation(spaceImgWall, action_drawwall, NULL, x, y, w, h); + space_action_from_location(spaceImgWall, action_drawwall, NULL, x, y, w, h); - //printSpace(spaceWall); + //space_print(spaceWall); return 0; } @@ -275,9 +275,9 @@ static void action_eventwall(space_t * space, wall_t * wall, shot_t * shot) arena_t *arena; tux_t *author; - arena = export_fce->fce_getCurrentArena(); + arena = export_fce->fce_arena_get_current(); - author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id); + author = space_get_object_id(arena->spaceTux, shot->author_id); if (author != NULL && author->bonus == BONUS_GHOST && author->bonus_time > 0) { @@ -285,24 +285,24 @@ static void action_eventwall(space_t * space, wall_t * wall, shot_t * shot) } if (shot->gun == GUN_BOMBBALL) { - if (export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT) { - export_fce->fce_boundBombBall(shot); + if (export_fce->fce_netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { + export_fce->fce_shot_bound_bombBall(shot); } return; } - //delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot); + //space_del_with_item(arena->spaceShot, shot, export_fce->fce_shot_destroy); shot->del = TRUE; } static void action_eventshot(space_t * space, shot_t * shot, space_t * p_spaceWall) { - actionSpaceFromLocation(p_spaceWall, action_eventwall, shot, shot->x, + space_action_from_location(p_spaceWall, action_eventwall, shot, shot->x, shot->y, shot->w, shot->h); if (shot->del == TRUE) { - delObjectFromSpaceWithObject(space, shot, export_fce->fce_destroyShot); + space_del_with_item(space, shot, export_fce->fce_shot_destroy); } } @@ -312,7 +312,7 @@ int event() return 0; } - actionSpace(export_fce->fce_getCurrentArena()->spaceShot, + space_action(export_fce->fce_arena_get_current()->spaceShot, action_eventshot, spaceWall); return 0; @@ -324,7 +324,7 @@ int isConflict(int x, int y, int w, int h) return 0; } - return isConflictWithObjectFromSpace(spaceWall, x, y, w, h); + return space_is_conflict_with_object(spaceWall, x, y, w, h); } void cmdArena(char *line) @@ -339,10 +339,10 @@ void recvMsg(char *msg) int destroy() { - destroySpaceWithObject(spaceWall, destroyWall); + space_destroy_with_item(spaceWall, destroyWall); #ifndef PUBLIC_SERVER - destroySpace(spaceImgWall); + space_destroy(spaceImgWall); #endif - destroyList(listWall); + list_destroy(listWall); return 0; } diff --git a/src/net/dns.c b/src/net/dns.c index 2167a52..156aeb4 100644 --- a/src/net/dns.c +++ b/src/net/dns.c @@ -12,7 +12,7 @@ #include "main.h" -char *getIPFormDNS(char *domain) +char *gns_resolv(char *domain) { struct hostent *host; diff --git a/src/net/dns.h b/src/net/dns.h index 281a056..38e6a9f 100644 --- a/src/net/dns.h +++ b/src/net/dns.h @@ -3,6 +3,6 @@ # define DNS_H -extern char *getIPFormDNS(char *domain); +extern char *gns_resolv(char *domain); #endif diff --git a/src/net/tcp.c b/src/net/tcp.c index 9efa0c2..85859e0 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -25,7 +25,7 @@ #include "tcp.h" -sock_tcp_t *newSockTcp(void) +sock_tcp_t *sock_tcp_new(void) { sock_tcp_t *new; @@ -35,7 +35,7 @@ sock_tcp_t *newSockTcp(void) return new; } -void destroySockTcp(sock_tcp_t * p) +void sock_tcp_destroy(sock_tcp_t * p) { assert(p != NULL); free(p); @@ -50,7 +50,7 @@ static int getProto(char *str) return -1; } -sock_tcp_t *bindTcpSocket(char *address, int port) +sock_tcp_t *sock_tcp_bind(char *address, int port) { sock_tcp_t *new; unsigned long param_setsock = 1; @@ -59,7 +59,7 @@ sock_tcp_t *bindTcpSocket(char *address, int port) assert(port > 0 && port < 65535); - new = newSockTcp(); + new = sock_tcp_new(); new->proto = getProto(address); ret = -1; // no Warnings @@ -77,7 +77,7 @@ sock_tcp_t *bindTcpSocket(char *address, int port) if (new->sock < 0) { fprintf(stderr, _("Unable to create socket when connecting!\n")); - destroySockTcp(new); + sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -117,7 +117,7 @@ sock_tcp_t *bindTcpSocket(char *address, int port) if (ret < 0) { fprintf(stderr, _("Unable to bint to port: %d\n"), port); - destroySockTcp(new); + sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -129,7 +129,7 @@ sock_tcp_t *bindTcpSocket(char *address, int port) return new; } -sock_tcp_t *getTcpNewClient(sock_tcp_t * p) +sock_tcp_t *sock_tcp_accept(sock_tcp_t * p) { sock_tcp_t *new; int client_len; @@ -137,7 +137,7 @@ sock_tcp_t *getTcpNewClient(sock_tcp_t * p) assert(p != NULL); assert(p->sock >= 0); - new = newSockTcp(); + new = sock_tcp_new(); new->proto = p->proto; if (new->proto == PROTO_TCPv4) { @@ -161,7 +161,7 @@ sock_tcp_t *getTcpNewClient(sock_tcp_t * p) if (new->sock < 0) { //printf("XXX\n"); - destroySockTcp(new); + sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -171,7 +171,7 @@ sock_tcp_t *getTcpNewClient(sock_tcp_t * p) return new; } -void getSockTcpIp(sock_tcp_t * p, char *str_ip, int len) +void sock_tcp_get_ip(sock_tcp_t * p, char *str_ip, int len) { assert(p != NULL); assert(str_ip != NULL); @@ -197,7 +197,7 @@ void getSockTcpIp(sock_tcp_t * p, char *str_ip, int len) #endif // SUPPORT_IPv6 } -int getSockTcpPort(sock_tcp_t * p) +int sock_tcp_get_port(sock_tcp_t * p) { assert(p != NULL); @@ -215,7 +215,7 @@ int getSockTcpPort(sock_tcp_t * p) return -1; } -sock_tcp_t *connectTcpSocket(char *ip, int port) +sock_tcp_t *sock_tcp_connect(char *ip, int port) { sock_tcp_t *new; int len; @@ -224,7 +224,7 @@ sock_tcp_t *connectTcpSocket(char *ip, int port) assert(ip != NULL); assert(port > 0 && port < 65535); - new = newSockTcp(); + new = sock_tcp_new(); new->proto = getProto(ip); ret = -1; // no Warnnings @@ -240,7 +240,7 @@ sock_tcp_t *connectTcpSocket(char *ip, int port) if (new->sock < 0) { fprintf(stderr, _("Unable to create TCP socket!\n")); - destroySockTcp(new); + sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -270,7 +270,7 @@ sock_tcp_t *connectTcpSocket(char *ip, int port) if (ret < 0) { fprintf(stderr, "Unable to connect on: \"%s\" port: \"%d\"\n", ip, port); - destroySockTcp(new); + sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -281,7 +281,7 @@ sock_tcp_t *connectTcpSocket(char *ip, int port) return new; } -int disableNagle(sock_tcp_t * p) +int sock_tcp_diable_nagle(sock_tcp_t * p) { int flag = 1; @@ -304,7 +304,7 @@ int disableNagle(sock_tcp_t * p) return result; } -int setTcpSockNonBlock(sock_tcp_t * p) +int sock_tcp_set_non_block(sock_tcp_t * p) { /* Set to nonblocking socket mode */ #ifndef __WIN32__ @@ -313,10 +313,10 @@ int setTcpSockNonBlock(sock_tcp_t * p) oldFlag = fcntl(p->sock, F_GETFL, 0); if (fcntl(p->sock, F_SETFL, oldFlag | O_NONBLOCK) == -1) { - //printf("error setTcpSockNonBlock\n"); + //printf("error sock_tcp_set_non_block\n"); return -1; } - //printf("setTcpSockNonBlock OK\n"); + //printf("sock_tcp_set_non_block OK\n"); #else unsigned long arg = 1; // Operation is FIONBIO. Parameter is pointer on non-zero number. @@ -328,7 +328,7 @@ int setTcpSockNonBlock(sock_tcp_t * p) return 0; } -int readTcpSocket(sock_tcp_t * p, void *address, int len) +int sock_tcp_read(sock_tcp_t * p, void *address, int len) { assert(p != NULL); assert(address != NULL); @@ -336,7 +336,7 @@ int readTcpSocket(sock_tcp_t * p, void *address, int len) return read(p->sock, address, len); } -int writeTcpSocket(sock_tcp_t * p, void *address, int len) +int sock_tcp_write(sock_tcp_t * p, void *address, int len) { assert(p != NULL); assert(address != NULL); @@ -344,12 +344,12 @@ int writeTcpSocket(sock_tcp_t * p, void *address, int len) return write(p->sock, address, len); } -void closeTcpSocket(sock_tcp_t * p) +void sock_tcp_close(sock_tcp_t * p) { assert(p != NULL); close(p->sock); - destroySockTcp(p); + sock_tcp_destroy(p); #ifdef __WIN32__ WSACleanup(); #endif diff --git a/src/net/tcp.h b/src/net/tcp.h index ae46f48..a9cdb4b 100644 --- a/src/net/tcp.h +++ b/src/net/tcp.h @@ -31,17 +31,17 @@ typedef struct struct_sock_tcp_t { # endif } sock_tcp_t; -extern sock_tcp_t *newSockTcp(void); -extern void destroySockTcp(sock_tcp_t * p); -extern sock_tcp_t *bindTcpSocket(char *addresss, int port); -extern sock_tcp_t *getTcpNewClient(sock_tcp_t * p); -extern void getSockTcpIp(sock_tcp_t * p, char *str_ip, int len); -extern int getSockTcpPort(sock_tcp_t * p); -extern sock_tcp_t *connectTcpSocket(char *ip, int port); -extern int disableNagle(sock_tcp_t * p); -extern int setTcpSockNonBlock(sock_tcp_t * p); -extern int readTcpSocket(sock_tcp_t * p, void *address, int len); -extern int writeTcpSocket(sock_tcp_t * p, void *address, int len); -extern void closeTcpSocket(sock_tcp_t * p); +extern sock_tcp_t *sock_tcp_new(void); +extern void sock_tcp_destroy(sock_tcp_t * p); +extern sock_tcp_t *sock_tcp_bind(char *addresss, int port); +extern sock_tcp_t *sock_tcp_accept(sock_tcp_t * p); +extern void sock_tcp_get_ip(sock_tcp_t * p, char *str_ip, int len); +extern int sock_tcp_get_port(sock_tcp_t * p); +extern sock_tcp_t *sock_tcp_connect(char *ip, int port); +extern int sock_tcp_diable_nagle(sock_tcp_t * p); +extern int sock_tcp_set_non_block(sock_tcp_t * p); +extern int sock_tcp_read(sock_tcp_t * p, void *address, int len); +extern int sock_tcp_write(sock_tcp_t * p, void *address, int len); +extern void sock_tcp_close(sock_tcp_t * p); #endif diff --git a/src/net/udp.c b/src/net/udp.c index 6f5a701..6d61a11 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -35,7 +35,7 @@ static int getProto(char *str) return -1; } -sock_udp_t *newSockUdp(void) +sock_udp_t *sock_udp_new(void) { sock_udp_t *new; @@ -45,20 +45,20 @@ sock_udp_t *newSockUdp(void) return new; } -void destroySockUdp(sock_udp_t * p) +void sock_udp_destroy(sock_udp_t * p) { assert(p != NULL); free(p); } -sock_udp_t *bindUdpSocket(char *address, int port) +sock_udp_t *sock_udp_bind(char *address, int port) { sock_udp_t *new; int res = -1; // no warninng assert(port > 0 && port < 65535); - new = newSockUdp(); + new = sock_udp_new(); new->proto = getProto(address); assert(new != NULL); @@ -75,7 +75,7 @@ sock_udp_t *bindUdpSocket(char *address, int port) if (new->sock < 0) { fprintf(stderr, _("Unable to create socket when binding!\n")); - destroySockUdp(new); + sock_udp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -103,7 +103,7 @@ sock_udp_t *bindUdpSocket(char *address, int port) if (res < 0) { fprintf(stderr, _("Unable to set socket %s %d!\n"), address, port); - destroySockUdp(new); + sock_udp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -113,14 +113,14 @@ sock_udp_t *bindUdpSocket(char *address, int port) return new; } -sock_udp_t *connectUdpSocket(char *address, int port) +sock_udp_t *sock_udp_connect(char *address, int port) { sock_udp_t *new; assert(address != NULL); assert(port > 0 && port < 65536); - new = newSockUdp(); + new = sock_udp_new(); new->proto = getProto(address); assert(new != NULL); @@ -137,7 +137,7 @@ sock_udp_t *connectUdpSocket(char *address, int port) if (new->sock < 0) { fprintf(stderr, _("Unable to create socket when connecting!\n")); - destroySockUdp(new); + sock_udp_destroy(new); #ifdef __WIN32__ WSACleanup(); #endif @@ -161,7 +161,7 @@ sock_udp_t *connectUdpSocket(char *address, int port) return new; } -int setUdpSockNonBlock(sock_udp_t * p) +int sock_udp_set_non_block(sock_udp_t * p) { /* Set to nonblocking socket mode */ #ifndef __WIN32__ @@ -183,7 +183,7 @@ int setUdpSockNonBlock(sock_udp_t * p) return 0; } -int readUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len) +int sock_udp_read(sock_udp_t * src, sock_udp_t * dst, void *address, int len) { int addrlen; int size = -1; // no warninng @@ -222,10 +222,10 @@ int readUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len) if (size < 0) { char str_ip[STR_IP_SIZE]; - getSockUdpIp(dst, str_ip, STR_IP_SIZE); + sock_udp_get_ip(dst, str_ip, STR_IP_SIZE); fprintf(stderr, _("Unable to read form socket %d %s %d!\n"), size, - str_ip, getSockUdpPort(dst)); + str_ip, sock_udp_get_port(dst)); #ifdef __WIN32__ WSACleanup(); @@ -236,7 +236,7 @@ int readUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len) return size; } -int writeUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len) +int sock_udp_write(sock_udp_t * src, sock_udp_t * dst, void *address, int len) { int addrlen; int size = -1; // no warninng @@ -263,10 +263,10 @@ int writeUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len) if (size < 0) { char str_ip[STR_IP_SIZE]; - getSockUdpIp(dst, str_ip, STR_IP_SIZE); + sock_udp_get_ip(dst, str_ip, STR_IP_SIZE); fprintf(stderr, _("Unable to write on socket %d %s %d %d!\n"), size, - str_ip, getSockUdpPort(dst), dst->proto); + str_ip, sock_udp_get_port(dst), dst->proto); //assert(0); #ifdef __WIN32__ @@ -278,7 +278,7 @@ int writeUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, int len) return size; } -void getSockUdpIp(sock_udp_t * p, char *str_ip, int len) +void sock_udp_get_ip(sock_udp_t * p, char *str_ip, int len) { assert(p != NULL); assert(str_ip != NULL); @@ -299,7 +299,7 @@ void getSockUdpIp(sock_udp_t * p, char *str_ip, int len) #endif } -int getSockUdpPort(sock_udp_t * p) +int sock_udp_get_port(sock_udp_t * p) { assert(p != NULL); @@ -318,7 +318,7 @@ int getSockUdpPort(sock_udp_t * p) } -void closeUdpSocket(sock_udp_t * p) +void sock_udp_close(sock_udp_t * p) { assert(p != NULL); @@ -328,7 +328,7 @@ void closeUdpSocket(sock_udp_t * p) closesocket(p->sock); //WSACleanup(); //kdyz ukoncime socket dobre neni treba cleanup #endif - destroySockUdp(p); + sock_udp_destroy(p); } #if 0 @@ -369,34 +369,34 @@ int main(int argc, char *argv[]) if (strcmp(argv[1], "s") == 0) { sock_udp_t *cli; - //sock = bindUdpSocket("::1", atoi(argv[2]), PROTO_UDPv6 ); - sock = bindUdpSocket("127.0.0.1", atoi(argv[2]), PROTO_UDPv4); + //sock = sock_udp_bind("::1", atoi(argv[2]), PROTO_UDPv6 ); + sock = sock_udp_bind("127.0.0.1", atoi(argv[2]), PROTO_UDPv4); - //cli = newSockUdp(PROTO_UDPv6); - cli = newSockUdp(PROTO_UDPv4); + //cli = sock_udp_new(PROTO_UDPv6); + cli = sock_udp_new(PROTO_UDPv4); while (1) { while (myWait(sock) == 0); memset(buf, 0, BUFSIZE); - ret = readUdpSocket(sock, cli, buf, BUFSIZE); - writeUdpSocket(sock, cli, buf, ret); + ret = sock_udp_read(sock, cli, buf, BUFSIZE); + sock_udp_write(sock, cli, buf, ret); } } if (strcmp(argv[1], "c") == 0) { - //sock = connectUdpSocket("::1", atoi(argv[2]), PROTO_UDPv6); - sock = connectUdpSocket("127.0.0.1", atoi(argv[2]), PROTO_UDPv4); + //sock = sock_udp_connect("::1", atoi(argv[2]), PROTO_UDPv6); + sock = sock_udp_connect("127.0.0.1", atoi(argv[2]), PROTO_UDPv4); strcpy(buf, "Hello world !\n"); - writeUdpSocket(sock, sock, buf, strlen(buf)); + sock_udp_write(sock, sock, buf, strlen(buf)); memset(buf, 0, BUFSIZE); - readUdpSocket(sock, sock, buf, BUFSIZE); + sock_udp_read(sock, sock, buf, BUFSIZE); printf("buf = %s", buf); //while(1)sleep(1); - closeUdpSocket(sock); + sock_udp_close(sock); } return 0; diff --git a/src/net/udp.h b/src/net/udp.h index c203323..35c9e18 100644 --- a/src/net/udp.h +++ b/src/net/udp.h @@ -28,16 +28,16 @@ typedef struct struct_sock_udp_t { struct sockaddr_in sockAddr; } sock_udp_t; -extern sock_udp_t *newSockUdp(void); -extern void destroySockUdp(sock_udp_t * p); -extern sock_udp_t *bindUdpSocket(char *address, int port); -extern sock_udp_t *connectUdpSocket(char *address, int port); -extern int setUdpSockNonBlock(sock_udp_t * p); -extern int readUdpSocket(sock_udp_t * src, sock_udp_t * dst, void *address, +extern sock_udp_t *sock_udp_new(void); +extern void sock_udp_destroy(sock_udp_t * p); +extern sock_udp_t *sock_udp_bind(char *address, int port); +extern sock_udp_t *sock_udp_connect(char *address, int port); +extern int sock_udp_set_non_block(sock_udp_t * p); +extern int sock_udp_read(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, +extern int sock_udp_write(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); +extern void sock_udp_get_ip(sock_udp_t * p, char *str_ip, int len); +extern int sock_udp_get_port(sock_udp_t * p); +extern void sock_udp_close(sock_udp_t * p); #endif diff --git a/src/screen/analyze.c b/src/screen/analyze.c index 2153e52..306c7bd 100644 --- a/src/screen/analyze.c +++ b/src/screen/analyze.c @@ -51,50 +51,50 @@ static void destroyAnalyze(analyze_t * p) static void hotkey_escape() { - setScreen("mainMenu"); + screen_set("mainMenu"); } -void startScreenAnalyze() +void analyze_start() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); } -void drawScreenAnalyze() +void analyze_draw() { widget_t *this; int i; - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); for (i = 0; i < listWidgetLabelName->count; i++) { this = (widget_t *) (listWidgetLabelName->list[i]); - drawWidgetLabel(this); + label_draw(this); } for (i = 0; i < listWidgetLabelScore->count; i++) { this = (widget_t *) (listWidgetLabelScore->list[i]); - drawWidgetLabel(this); + label_draw(this); } - drawWidgetLabel(widgetLabelMsg); - drawWidgetButton(button_ok); + label_draw(widgetLabelMsg); + button_draw(button_ok); } -void eventScreenAnalyze() +void analyze_event() { - eventWidgetButton(button_ok); + button_event(button_ok); } -void stopScreenAnalyze() +void analyze_stop() { - destroyWidgetLabel(widgetLabelMsg); - widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); + label_destroy(widgetLabelMsg); + widgetLabelMsg = label_new("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); } static void eventWidget(void *p) @@ -104,33 +104,33 @@ static void eventWidget(void *p) button = (widget_t *) (p); if (button == button_ok) { - setScreen("mainMenu"); + screen_set("mainMenu"); } } -void restartAnalyze() +void analyze_restart() { - destroyListItem(listWidgetLabelName, destroyWidgetLabel); - destroyListItem(listWidgetLabelScore, destroyWidgetLabel); - destroyListItem(listAnalyze, destroyAnalyze); + list_destroy_item(listWidgetLabelName, label_destroy); + list_destroy_item(listWidgetLabelScore, label_destroy); + list_destroy_item(listAnalyze, destroyAnalyze); - listWidgetLabelName = newList(); - listWidgetLabelScore = newList(); - listAnalyze = newList(); + listWidgetLabelName = list_new(); + listWidgetLabelScore = list_new(); + listAnalyze = list_new(); } -void addAnalyze(char *name, int score) +void analyze_add(char *name, int score) { - addList(listAnalyze, newAnalyze(name, score)); + list_add(listAnalyze, newAnalyze(name, score)); } -void setMsgToAnalyze(char *msg) +void analyze_set_msg(char *msg) { - destroyWidgetLabel(widgetLabelMsg); - widgetLabelMsg = newWidgetLabel(msg, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); + label_destroy(widgetLabelMsg); + widgetLabelMsg = label_new(msg, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); } -void endAnalyze() +void analyze_end() { int i; @@ -140,46 +140,46 @@ void endAnalyze() this = (analyze_t *) (listAnalyze->list[i]); - addList(listWidgetLabelName, newWidgetLabel(this->name, 100, + list_add(listWidgetLabelName, label_new(this->name, 100, 200 + 20 * i, WIDGET_LABEL_LEFT)); str = getString(this->score); - addList(listWidgetLabelScore, newWidgetLabel(str, WINDOW_SIZE_X - 100, + list_add(listWidgetLabelScore, label_new(str, WINDOW_SIZE_X - 100, 200 + 20 * i, WIDGET_LABEL_RIGHT)); free(str); } } -void initScreenAnalyze() +void analyze_init() { image_t *image; - image = getImage(IMAGE_GROUP_BASE, "screen_main"); - image_backgorund = newWidgetImage(0, 0, image); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = wid_image_new(0, 0, image); - listWidgetLabelName = newList(); - listWidgetLabelScore = newList(); - listAnalyze = newList(); + listWidgetLabelName = list_new(); + listWidgetLabelScore = list_new(); + listAnalyze = list_new(); - button_ok = newWidgetButton("OK", WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + button_ok = button_new("OK", WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, WINDOW_SIZE_Y - 100, eventWidget); - registerScreen( newScreen("analyze", startScreenAnalyze, eventScreenAnalyze, - drawScreenAnalyze, stopScreenAnalyze)); + screen_register( screen_new("analyze", analyze_start, analyze_event, + analyze_draw, analyze_stop)); - widgetLabelMsg = newWidgetLabel("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); + widgetLabelMsg = label_new("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); } -void quitScreenAnalyze() +void analyze_quit() { - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyListItem(listWidgetLabelName, destroyWidgetLabel); - destroyListItem(listWidgetLabelScore, destroyWidgetLabel); - destroyListItem(listAnalyze, destroyAnalyze); + list_destroy_item(listWidgetLabelName, label_destroy); + list_destroy_item(listWidgetLabelScore, label_destroy); + list_destroy_item(listAnalyze, destroyAnalyze); - destroyWidgetButton(button_ok); - destroyWidgetLabel(widgetLabelMsg); + button_destroy(button_ok); + label_destroy(widgetLabelMsg); } diff --git a/src/screen/analyze.h b/src/screen/analyze.h index 8f975b4..683f26e 100644 --- a/src/screen/analyze.h +++ b/src/screen/analyze.h @@ -10,15 +10,15 @@ typedef struct analyze_struct { 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(); +extern void analyze_start(); +extern void analyze_draw(); +extern void analyze_event(); +extern void analyze_stop(); +extern void analyze_restart(); +extern void analyze_add(char *name, int score); +extern void analyze_set_msg(char *msg); +extern void analyze_end(); +extern void analyze_init(); +extern void analyze_quit(); #endif diff --git a/src/screen/browser.c b/src/screen/browser.c index d9bf61e..9e4db3a 100644 --- a/src/screen/browser.c +++ b/src/screen/browser.c @@ -74,57 +74,57 @@ static server_t *server_getcurr(); static void hotkey_escape() { - setScreen("gameType"); + screen_set("gameType"); } -void startScreenBrowser() +void browser_start() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); LoadServers(); } -void drawScreenBrowser() +void browser_draw() { - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); - drawWidgetLabel(label_server); - drawWidgetLabel(label_version); - drawWidgetLabel(label_address); - drawWidgetLabel(label_arena); - drawWidgetLabel(label_players); - drawWidgetLabel(label_ping); + label_draw(label_server); + label_draw(label_version); + label_draw(label_address); + label_draw(label_arena); + label_draw(label_players); + label_draw(label_ping); - drawWidgetSelect(select_server); + select_draw(select_server); - drawWidgetButton(button_play); - drawWidgetButton(button_back); - drawWidgetButton(button_refresh); + button_draw(button_play); + button_draw(button_back); + button_draw(button_refresh); } -void eventScreenBrowser() +void browser_event() { - eventWidgetSelect(select_server); + select_event(select_server); - eventWidgetButton(button_play); - eventWidgetButton(button_back); - eventWidgetButton(button_refresh); + button_event(button_play); + button_event(button_back); + button_event(button_refresh); } -void stopScreenBrowser() +void browser_stop() { unsigned i = 0; server_t *server; - //destroyListItem(select_server->list, free); - //select_server->list = newList(); - removeAllFromWidgetSelect(select_server); + //list_destroy_item(select_server->list, free); + //select_server->list = list_new(); + select_remove_all(select_server); - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); while (1) { i = 0; @@ -175,14 +175,14 @@ static void eventWidget(void *p) char *address = (char *) inet_ntoa(srv); setSettingGameType(NET_GAME_TYPE_CLIENT); - setSettingIP(address); - setSettingPort(server->port); + gameType_set_ip(address); + gameType_set_port(server->port); - setScreen("world"); + screen_set("world"); } if (button == button_back) { - setScreen("gameType"); + screen_set("gameType"); } if (button == button_refresh) { @@ -197,7 +197,7 @@ server_t *server_getcurr() for (server = server_list.next; server != &server_list; server = server->next) { - if (i == getWidgetSelectIndex(select_server)) + if (i == select_get_index(select_server)) return server; i++; @@ -437,7 +437,7 @@ static int LoadServers() struct sockaddr_in server; char *master_server_ip; - master_server_ip = getIPFormDNS(NET_MASTER_SERVER_DOMAIN); + master_server_ip = gns_resolv(NET_MASTER_SERVER_DOMAIN); //printf("master_server_ip = %s\n", master_server_ip); @@ -590,7 +590,7 @@ static int LoadServers() memcpy(list + 83, buf, strlen(buf)); } - addToWidgetSelect(select_server, list); + select_add(select_server, list); // add into list ctx->next = &server_list; @@ -610,10 +610,10 @@ static int LoadServers() static int RefreshServers() { /* - destroyListItem(select_server->list, free); - select_server->list = newList(); + list_destroy_item(select_server->list, free); + select_server->list = list_new(); */ - removeAllFromWidgetSelect(select_server); + select_remove_all(select_server); struct in_addr srv; @@ -672,60 +672,60 @@ static int RefreshServers() memcpy(list + 83, buf, strlen(buf)); } - addToWidgetSelect(select_server, list); + select_add(select_server, list); } return 1; } -void initScreenBrowser() +void browser_init() { image_t *image; - image = getImage(IMAGE_GROUP_BASE, "screen_main"); - image_backgorund = newWidgetImage(0, 0, image); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = wid_image_new(0, 0, image); button_back = - newWidgetButton(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); + button_new(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); button_play = - newWidgetButton(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, + button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); button_refresh = - newWidgetButton(_("Refresh"), WINDOW_SIZE_X / 2 - 50, + button_new(_("Refresh"), WINDOW_SIZE_X / 2 - 50, WINDOW_SIZE_Y - 100, eventWidget); - label_server = newWidgetLabel(_("server"), 120, 145, WIDGET_LABEL_LEFT); - label_version = newWidgetLabel(_("version"), 290, 145, WIDGET_LABEL_LEFT); - label_address = newWidgetLabel(_("IP"), 400, 145, WIDGET_LABEL_LEFT); - label_arena = newWidgetLabel(_("arena"), 550, 145, WIDGET_LABEL_LEFT); - label_players = newWidgetLabel(_("clients"), 645, 145, WIDGET_LABEL_LEFT); - label_ping = newWidgetLabel(_("ping"), 720, 145, WIDGET_LABEL_LEFT); + label_server = label_new(_("server"), 120, 145, WIDGET_LABEL_LEFT); + label_version = label_new(_("version"), 290, 145, WIDGET_LABEL_LEFT); + label_address = label_new(_("IP"), 400, 145, WIDGET_LABEL_LEFT); + label_arena = label_new(_("arena"), 550, 145, WIDGET_LABEL_LEFT); + label_players = label_new(_("clients"), 645, 145, WIDGET_LABEL_LEFT); + label_ping = label_new(_("ping"), 720, 145, WIDGET_LABEL_LEFT); - select_server = newWidgetSelect(50, label_server->y + 40, eventWidget); + select_server = select_new(50, label_server->y + 40, eventWidget); - registerScreen(newScreen - ("browser", startScreenBrowser, eventScreenBrowser, - drawScreenBrowser, stopScreenBrowser)); + screen_register(screen_new + ("browser", browser_start, browser_event, + browser_draw, browser_stop)); server_list.next = &server_list; server_list.prev = &server_list; } -void quitScreenBrowser() +void browser_quit() { - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyWidgetButton(button_play); - destroyWidgetButton(button_back); - destroyWidgetButton(button_refresh); + button_destroy(button_play); + button_destroy(button_back); + button_destroy(button_refresh); - destroyWidgetLabel(label_server); - destroyWidgetLabel(label_version); - destroyWidgetLabel(label_address); - destroyWidgetLabel(label_arena); - destroyWidgetLabel(label_players); - destroyWidgetLabel(label_ping); + label_destroy(label_server); + label_destroy(label_version); + label_destroy(label_address); + label_destroy(label_arena); + label_destroy(label_players); + label_destroy(label_ping); - destroyWidgetSelect(select_server); + select_destroy(select_server); } diff --git a/src/screen/browser.h b/src/screen/browser.h index e810e58..eb22a05 100644 --- a/src/screen/browser.h +++ b/src/screen/browser.h @@ -23,11 +23,11 @@ typedef struct server_context { } server_t; -extern void startScreenBrowser(); -extern void drawScreenBrowser(); -extern void eventScreenBrowser(); -extern void stopScreenBrowser(); -extern void initScreenBrowser(); -extern void quitScreenBrowser(); +extern void browser_start(); +extern void browser_draw(); +extern void browser_event(); +extern void browser_stop(); +extern void browser_init(); +extern void browser_quit(); #endif diff --git a/src/screen/choiceArena.c b/src/screen/choiceArena.c index bf60c46..9e0d72a 100644 --- a/src/screen/choiceArena.c +++ b/src/screen/choiceArena.c @@ -47,54 +47,54 @@ static arenaFile_t *currentArena; static void hotkey_escape() { - setScreen("gameType"); + screen_set("gameType"); } -void startScreenChoiceArena() +void screen_startChoiceArena() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); } -void drawScreenChoiceArena() +void choiceArena_draw() { int i; - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); - drawWidgetButton(button_play); - drawWidgetButton(button_back); - if (show_map_buttons.next) { drawWidgetButton(button_next); } - if (show_map_buttons.prev) { drawWidgetButton(button_prev); } + button_draw(button_play); + button_draw(button_back); + if (show_map_buttons.next) { button_draw(button_next); } + if (show_map_buttons.prev) { button_draw(button_prev); } for (i = show_map_buttons.min ; i < show_map_buttons.max; i++) { - drawWidgetButtonimage((widget_t*)listAllWidgetButtonimage->list[i]); + buttonImage_draw((widget_t*)listAllWidgetButtonimage->list[i]); } } -void eventScreenChoiceArena() +void choiceArena_event() { int i; - eventWidgetButton(button_play); - eventWidgetButton(button_back); - if (show_map_buttons.next) { eventWidgetButton(button_next); } - if (show_map_buttons.prev) { eventWidgetButton(button_prev); } + button_event(button_play); + button_event(button_back); + if (show_map_buttons.next) { button_event(button_next); } + if (show_map_buttons.prev) { button_event(button_prev); } for (i = show_map_buttons.min ; i < show_map_buttons.max; i++) { - eventWidgetButtonimage((widget_t*)listAllWidgetButtonimage->list[i]); + buttonImage_event((widget_t*)listAllWidgetButtonimage->list[i]); } } void stopScreenChoiceArena() { - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); } -static void eventWidgetButtonImage(void *p) +static void button_eventImage(void *p) { widget_t *buttonimage; int i; @@ -107,30 +107,30 @@ static void eventWidgetButtonImage(void *p) this = (widget_t *) (listAllWidgetButtonimage->list[i]); if (buttonimage == this) { - setWidgetButtonimageActive(this, TRUE); - currentArena = getArenaFile(i); + buttonImage_set_active(this, TRUE); + currentArena = arenaFile_get(i); } else { - setWidgetButtonimageActive(this, FALSE); + buttonImage_set_active(this, FALSE); } } } -arenaFile_t *getChoiceArena() +arenaFile_t *choiceArena_get() { return currentArena; } -void setChoiceArena(arenaFile_t * arenaFile) +void choiceArena_set(arenaFile_t * arenaFile) { widget_t *widget_buttonimage; int id; - id = getArenaFileID(arenaFile); + id = arenaFile_get_id(arenaFile); currentArena = arenaFile; if (id >= 0) { widget_buttonimage = (widget_t *) listAllWidgetButtonimage->list[id]; - setWidgetButtonimageActive(widget_buttonimage, TRUE); + buttonImage_set_active(widget_buttonimage, TRUE); } } @@ -141,11 +141,11 @@ static void eventWidget(void *p) button = (widget_t *) (p); if (button == button_play) { - setScreen("world"); + screen_set("world"); } if (button == button_back) { - setScreen("gameType"); + screen_set("gameType"); } if (button == button_next) { if (show_map_buttons.next) { @@ -168,42 +168,42 @@ static void eventWidget(void *p) static void activateHandledMapButtonGroup(void) { int min = handled_map_button_group * 6; min = min < 0 ? 0 : min; - min = min <= getArenaCount() ? min : getArenaCount(); - int max = min+6 <= getArenaCount() ? min+6 : getArenaCount(); + min = min <= arenaFile_get_count() ? min : arenaFile_get_count(); + int max = min+6 <= arenaFile_get_count() ? min+6 : arenaFile_get_count(); if (min) { show_map_buttons.prev = 1; } else { show_map_buttons.prev = 0; } - if (max < getArenaCount()) { show_map_buttons.next = 1; } + if (max < arenaFile_get_count()) { show_map_buttons.next = 1; } else { show_map_buttons.next = 0; } show_map_buttons.min = min; show_map_buttons.max = max; } -void initScreenChoiceArena() +void choiceArena_init() { image_t *image; int i; - image = getImage(IMAGE_GROUP_BASE, "screen_main"); - image_backgorund = newWidgetImage(0, 0, image); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = wid_image_new(0, 0, image); - button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); - button_play = newWidgetButton(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); + button_back = button_new(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); + button_play = button_new(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); - button_prev = newWidgetButton(_("prev maps"), 250, WINDOW_SIZE_Y - 100, eventWidget); - button_next = newWidgetButton(_("next maps"), WINDOW_SIZE_X-350, WINDOW_SIZE_Y - 100, eventWidget); + button_prev = button_new(_("prev maps"), 250, WINDOW_SIZE_Y - 100, eventWidget); + button_next = button_new(_("next maps"), WINDOW_SIZE_X-350, WINDOW_SIZE_Y - 100, eventWidget); - listAllWidgetButtonimage = newList(); + listAllWidgetButtonimage = list_new(); currentArena = NULL; - for (i = 0; i < getArenaCount(); i++) { + for (i = 0; i < arenaFile_get_count(); i++) { widget_t *widget_buttonimage; arenaFile_t *arenaFile; int x, y; - arenaFile = getArenaFile(i); - //image = addImageData(getArenaImage(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE); - image = loadImageFromArena(arenaFile, getArenaImage(arenaFile), + arenaFile = arenaFile_get(i); + //image = image_add(arenaFile_get_image(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE); + image = arenaFile_load_image(arenaFile, arenaFile_get_image(arenaFile), IMAGE_GROUP_BASE, "none", IMAGE_NO_ALPHA); // only 6 map buttons can be shown at once; @@ -214,32 +214,32 @@ void initScreenChoiceArena() x = 100 + 200 * (pos - 3 * (pos / 3)); y = 150 + 200 * (pos / 3); - widget_buttonimage = newWidgetButtonimage(image, x, y, eventWidgetButtonImage); + widget_buttonimage = buttonImage_new(image, x, y, button_eventImage); /* if( i == choiceArenaId ) { widget_buttonimage->active = 1; } */ - addList(listAllWidgetButtonimage, widget_buttonimage); + list_add(listAllWidgetButtonimage, widget_buttonimage); handled_map_button_group = 0; activateHandledMapButtonGroup(); } - registerScreen( newScreen("chiceArena", startScreenChoiceArena, - eventScreenChoiceArena, drawScreenChoiceArena, + screen_register( screen_new("chiceArena", screen_startChoiceArena, + choiceArena_event, choiceArena_draw, stopScreenChoiceArena)); } -void quitScreenChoiceArena() +void choiceArena_quit() { - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyWidgetButton(button_play); - destroyWidgetButton(button_back); + button_destroy(button_play); + button_destroy(button_back); - destroyWidgetButton(button_next); - destroyWidgetButton(button_prev); + button_destroy(button_next); + button_destroy(button_prev); - destroyListItem(listAllWidgetButtonimage, destroyWidgetButtonimage); + list_destroy_item(listAllWidgetButtonimage, buttonImage_destroy); } diff --git a/src/screen/choiceArena.h b/src/screen/choiceArena.h index dbe12de..163ab60 100644 --- a/src/screen/choiceArena.h +++ b/src/screen/choiceArena.h @@ -9,11 +9,11 @@ # define SCREENSHOT_ARENA_WIDTH 160 # define SCREENSHOT_ARENA_HEIGHT 107 -extern void drawScreenChoiceArena(); -extern void eventScreenChoiceArena(); -extern arenaFile_t *getChoiceArena(); -extern void setChoiceArena(arenaFile_t * arenaFile); -extern void initScreenChoiceArena(); -extern void quitScreenChoiceArena(); +extern void choiceArena_draw(); +extern void choiceArena_event(); +extern arenaFile_t *choiceArena_get(); +extern void choiceArena_set(arenaFile_t * arenaFile); +extern void choiceArena_init(); +extern void choiceArena_quit(); #endif diff --git a/src/screen/credits.c b/src/screen/credits.c index 93745c2..c9521b1 100644 --- a/src/screen/credits.c +++ b/src/screen/credits.c @@ -31,26 +31,26 @@ static int creditExists; static void hotkey_escape() { - setScreen("mainMenu"); + screen_set("mainMenu"); } -void startScreenCredits() +void scredits_start() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif offset = 0; - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); } -void drawScreenCredits() +void scredits_draw() { int i; - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); - drawWidgetButton(button_back); + button_draw(button_back); for (i = 0; i < listWidgetLabel->count; i++) { int z; @@ -63,7 +63,7 @@ void drawScreenCredits() this->y += offset; if (this->y > SCREEN_CREDITS_OFFSET_MIN && this->y < SCREEN_CREDITS_OFFSET_MAX) { - drawWidgetLabel(this); + label_draw(this); } this->y = z; @@ -71,9 +71,9 @@ void drawScreenCredits() } -void eventScreenCredits() +void scredits_event() { - eventWidgetButton(button_back); + button_event(button_back); offset -= SCREEN_CREDITS_OFFSET_SPEED; @@ -84,9 +84,9 @@ void eventScreenCredits() //printf("offset = %d\n", offset); } -void stopScreenCredits() +void scredits_stop() { - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); } static void eventWidget(void *p) @@ -96,26 +96,26 @@ static void eventWidget(void *p) button = (widget_t *) (p); if (button == button_back) { - setScreen("mainMenu"); + screen_set("mainMenu"); } } -void initScreenCredits() +void scredits_init() { image_t *image; int i; - image = getImage(IMAGE_GROUP_BASE, "screen_main"); - image_backgorund = newWidgetImage(0, 0, image); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = wid_image_new(0, 0, image); - button_back = newWidgetButton(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + button_back = button_new(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, WINDOW_SIZE_Y - 80, eventWidget); - listWidgetLabel = newList(); + listWidgetLabel = list_new(); if (tryExistFile(PATH_DOC SCREEN_CREDITS_FILE) == 0) { creditExists = 1; - textFile = loadTextFile(PATH_DOC SCREEN_CREDITS_FILE); + textFile = textFile_load(PATH_DOC SCREEN_CREDITS_FILE); for (i = 0; i < textFile->text->count; i++) { widget_t *label; @@ -123,11 +123,11 @@ void initScreenCredits() line = (char *) textFile->text->list[i]; - label = newWidgetLabel(line, WINDOW_SIZE_X / 2 - WINDOW_SIZE_X / 4, + label = label_new(line, WINDOW_SIZE_X / 2 - WINDOW_SIZE_X / 4, (WINDOW_SIZE_Y - 100) + i * 20, WIDGET_LABEL_LEFT); - addList(listWidgetLabel, label); + list_add(listWidgetLabel, label); } } else { for (i = 0; i < 5; i++) { @@ -138,26 +138,26 @@ void initScreenCredits() sprintf(line, _("Credit file not found... %s/%s"), PATH_DOC, SCREEN_CREDITS_FILE); - label = newWidgetLabel(line, WINDOW_SIZE_X / 2, + label = label_new(line, WINDOW_SIZE_X / 2, (WINDOW_SIZE_Y - 100) + i * 20, WIDGET_LABEL_CENTER); - addList(listWidgetLabel, label); + list_add(listWidgetLabel, label); } } - registerScreen(newScreen ("credits", startScreenCredits, eventScreenCredits, - drawScreenCredits, stopScreenCredits)); + screen_register(screen_new ("credits", scredits_start, scredits_event, + scredits_draw, scredits_stop)); } -void quitScreenCredits() +void scredits_quit() { - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyWidgetButton(button_back); - destroyListItem(listWidgetLabel, destroyWidgetLabel); + button_destroy(button_back); + list_destroy_item(listWidgetLabel, label_destroy); if (creditExists) { - destroyTextFile(textFile); + textFile_destroy(textFile); } } diff --git a/src/screen/credits.h b/src/screen/credits.h index 37c25f3..0b05312 100644 --- a/src/screen/credits.h +++ b/src/screen/credits.h @@ -10,11 +10,11 @@ # 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(); +extern void scredits_start(); +extern void scredits_draw(); +extern void scredits_event(); +extern void scredits_stop(); +extern void scredits_init(); +extern void scredits_quit(); #endif diff --git a/src/screen/downArena.c b/src/screen/downArena.c index 3328046..7752513 100644 --- a/src/screen/downArena.c +++ b/src/screen/downArena.c @@ -53,8 +53,8 @@ static int countSendMsg; static void setStatusString(char *s) { printf("status -> %s\n", s); - destroyWidgetLabel(label_status); - label_status = newWidgetLabel(s, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); + label_destroy(label_status); + label_status = label_new(s, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); } static void connectToDownServer() @@ -62,38 +62,38 @@ static void connectToDownServer() char status[STR_SIZE]; char msg[STR_PROTO_SIZE]; - sock_server_tcp = connectTcpSocket(getSettingIP(), getSettingPort()); + sock_server_tcp = sock_tcp_connect(publicServer_get_settingIP(), publicServer_get_settingPort()); if( sock_server_tcp == NULL ) { - sprintf(status, "I do not connect to %s %d TCP down server", getSettingIP(), getSettingPort()); + sprintf(status, "I do not connect to %s %d TCP down server", publicServer_get_settingIP(), publicServer_get_settingPort()); setStatusString(status); return; } - setTcpSockNonBlock(sock_server_tcp); + sock_tcp_set_non_block(sock_server_tcp); - recvBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE); - sendBuffer = newBuffer(DOWN_ARENA_BUFFER_SIZE); + recvBuffer = buffer_new(DOWN_ARENA_BUFFER_SIZE); + sendBuffer = buffer_new(DOWN_ARENA_BUFFER_SIZE); status_tcp_socket = DOWN_SERVER_STATUS_OK; file = NULL; countSendMsg = 0; - timeSendMsg = getMyTime(); + timeSendMsg = timer_get_current_time(); sprintf(msg, "GETARENA %s\n", arenaNetName); - addBuffer(sendBuffer, msg, strlen(msg)); + buffer_append(sendBuffer, msg, strlen(msg)); - sprintf(status, "Connect to %s %d TCP down server", getSettingIP(), getSettingPort()); + sprintf(status, "Connect to %s %d TCP down server", publicServer_get_settingIP(), publicServer_get_settingPort()); setStatusString(status); } static void closeConnectFromDownServer() { - closeTcpSocket(sock_server_tcp); - destroyBuffer(recvBuffer); - destroyBuffer(sendBuffer); + sock_tcp_close(sock_server_tcp); + buffer_destroy(recvBuffer); + buffer_destroy(sendBuffer); sock_server_tcp = NULL; recvBuffer = NULL; sendBuffer = NULL; @@ -106,52 +106,52 @@ static void sendStatusToGameServer() if( countSendMsg > DOWN_ARENA_MAX_SEND_MSG_STATUS ) { char status[STR_SIZE]; - sprintf(status, "Game server %s %d is down", getSettingIP(), getSettingPort()); + sprintf(status, "Game server %s %d is down", publicServer_get_settingIP(), publicServer_get_settingPort()); setStatusString(status); return; } - timeSendMsg = getMyTime(); + timeSendMsg = timer_get_current_time(); countSendMsg++; printf("countSendMsg = %d\n", countSendMsg++); - if( writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0 ) + if( sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0 ) { char status[STR_SIZE]; - sprintf(status, "I do not send message to %s %d UDP game server", getSettingIP(), getSettingPort()); + sprintf(status, "I do not send message to %s %d UDP game server", publicServer_get_settingIP(), publicServer_get_settingPort()); setStatusString(status); } } -void startScreenDownArena() +void downArena_start() { char status[STR_SIZE]; strcpy(str_status, "none"); memset(arenaNetName, 0, STR_SIZE); - sock_server_udp = connectUdpSocket(getSettingIP(), getSettingPort()); + sock_server_udp = sock_udp_connect(publicServer_get_settingIP(), publicServer_get_settingPort()); if (sock_server_udp == NULL) { - sprintf(status, "I do not connect to %s %d UDP game server", getSettingIP(), getSettingPort()); + sprintf(status, "I do not connect to %s %d UDP game server", publicServer_get_settingIP(), publicServer_get_settingPort()); setStatusString(status); return; } - setUdpSockNonBlock(sock_server_udp); + sock_udp_set_non_block(sock_server_udp); - sprintf(status, "Connect to %s %d UDP game server", getSettingIP(), getSettingPort()); + sprintf(status, "Connect to %s %d UDP game server", publicServer_get_settingIP(), publicServer_get_settingPort()); setStatusString(status); sendStatusToGameServer(); } -void drawScreenDownArena() +void downArena_draw() { - drawWidgetImage(image_backgorund); - drawWidgetLabel(label_status); - drawWidgetButton(button_back); + wid_image_draw(image_backgorund); + label_draw(label_status); + button_draw(button_back); } static void proto_ok(char *line) @@ -160,7 +160,7 @@ static void proto_ok(char *line) fileSize = atoi(line + 3); fileOffset = 0; - sprintf(path, "%s/%s.zip", getHomeDirector(), arenaNetName); + sprintf(path, "%s/%s.zip", homeDirector_get(), arenaNetName); //printf("path = %s\n", path); file = fopen(path, "wb"); } @@ -191,9 +191,9 @@ static int downArenaFile() void *data; int len; - len = getBufferSize(recvBuffer); - data = getBufferData(recvBuffer); - cutBuffer(recvBuffer, len); + len = buffer_get_size(recvBuffer); + data = buffer_get_data(recvBuffer); + buffer_cut(recvBuffer, len); fwrite(data, len, 1, file); fileOffset += len; @@ -212,14 +212,14 @@ static int eventRecvBuffer() memset(buffer, 0, STR_PROTO_SIZE); - ret = readTcpSocket(sock_server_tcp, buffer, STR_PROTO_SIZE - 1); - //if (ret <= 0) printf("readTcpSocket = %d\n", ret); + ret = sock_tcp_read(sock_server_tcp, buffer, STR_PROTO_SIZE - 1); + //if (ret <= 0) printf("sock_tcp_read = %d\n", ret); if (ret < 0) { return -1; } - if (addBuffer(recvBuffer, buffer, ret) < 0) { + if (buffer_append(recvBuffer, buffer, ret) < 0) { char status[STR_SIZE]; sprintf(status, "Error -- recv buffer is full"); setStatusString(status); @@ -227,7 +227,7 @@ static int eventRecvBuffer() return -1; } - if (file == NULL && getBufferLine(recvBuffer, line, STR_PROTO_SIZE) >= 0) { + if (file == NULL && buffer_get_line(recvBuffer, line, STR_PROTO_SIZE) >= 0) { eventProto(line); return ret; } @@ -245,21 +245,21 @@ static int eventSendBuffer() int len; int res; - len = getBufferSize(sendBuffer); + len = buffer_get_size(sendBuffer); if (len == 0) { return -1; } - data = getBufferData(sendBuffer); + data = buffer_get_data(sendBuffer); - res = writeTcpSocket(sock_server_tcp, data, len); + res = sock_tcp_write(sock_server_tcp, data, len); if (res < 0) { return -1; } - cutBuffer(sendBuffer, res); + buffer_cut(sendBuffer, res); return res; } @@ -277,12 +277,12 @@ static void readArenaFromStatus() offset_end = strstr(offset_begin, "\n"); if (offset_end != NULL) { - closeUdpSocket(sock_server_udp); + sock_udp_close(sock_server_udp); sock_server_udp = NULL; strncpy(arenaNetName, offset_begin, offset_end - offset_begin); - if (getArenaFileFormNetName(arenaNetName) != NULL) { - setScreen("world"); + if (arenaFile_get_file_format_net_name(arenaNetName) != NULL) { + screen_set("world"); return; } @@ -295,19 +295,19 @@ static void readArenaFromStatus() static void eventStatus() { - if( getMyTime() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT ) + if( timer_get_current_time() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT ) { sendStatusToGameServer(); } - if( readUdpSocket(sock_server_udp, sock_server_udp, str_status, STR_PROTO_SIZE - 1) > 0 ) + if( sock_udp_read(sock_server_udp, sock_server_udp, str_status, STR_PROTO_SIZE - 1) > 0 ) { //printf("str_status = %s\n", str_status); readArenaFromStatus(); } } -void eventScreenDownArena() +void downArena_event() { int i; @@ -331,14 +331,14 @@ void eventScreenDownArena() fclose(file); file = NULL; closeConnectFromDownServer(); - loadArenaFile(path); - setScreen("world"); + arenaFile_load(path); + screen_set("world"); } - eventWidgetButton(button_back); + button_event(button_back); } -void stopScreenDownArena() +void downArena_stop() { if (file != NULL) { unlink(path); @@ -349,7 +349,7 @@ void stopScreenDownArena() } if (sock_server_udp != NULL) { - closeUdpSocket(sock_server_udp); + sock_udp_close(sock_server_udp); } } @@ -361,31 +361,31 @@ static void eventWidget(void *p) button = (widget_t *) (p); if (button == button_back) { - setScreen("mainMenu"); + screen_set("mainMenu"); } } -void initScreenDownArena() +void downArena_init() { image_t *image; - image = getImage(IMAGE_GROUP_BASE, "screen_main"); - image_backgorund = newWidgetImage(0, 0, image); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = wid_image_new(0, 0, image); button_back = - newWidgetButton(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + button_new(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, WINDOW_SIZE_Y - 80, eventWidget); label_status = - newWidgetLabel("none", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); + label_new("none", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); - registerScreen( newScreen("downArena", startScreenDownArena, eventScreenDownArena, - drawScreenDownArena, stopScreenDownArena)); + screen_register( screen_new("downArena", downArena_start, downArena_event, + downArena_draw, downArena_stop)); } -void quitScreenDownArena() +void downArena_quit() { - destroyWidgetImage(image_backgorund); - destroyWidgetButton(button_back); - destroyWidgetLabel(label_status); + wid_image_destroy(image_backgorund); + button_destroy(button_back); + label_destroy(label_status); } diff --git a/src/screen/downArena.h b/src/screen/downArena.h index d9f25d7..2ce5f07 100644 --- a/src/screen/downArena.h +++ b/src/screen/downArena.h @@ -12,11 +12,11 @@ # define DOWN_ARENA_MAX_TIEMOUT_LIMIT 500 # define DOWN_ARENA_COUNT_READ_SOCKET 100 -extern void startScreenDownArena(); -extern void drawScreenDownArena(); -extern void eventScreenDownArena(); -extern void stopScreenDownArena(); -extern void initScreenDownArena(); -extern void quitScreenDownArena(); +extern void downArena_start(); +extern void downArena_draw(); +extern void downArena_event(); +extern void downArena_stop(); +extern void downArena_init(); +extern void downArena_quit(); #endif diff --git a/src/screen/gameType.c b/src/screen/gameType.c index a8f0b2a..f143a2b 100644 --- a/src/screen/gameType.c +++ b/src/screen/gameType.c @@ -62,9 +62,9 @@ static void loadSession(widget_t * p) director_t *director; int i; - director = loadDirector(getHomeDirector()); + director = director_load(homeDirector_get()); - removeAllFromWidgetSelect(p); + select_remove_all(p); if (director == NULL) { return; @@ -76,79 +76,79 @@ static void loadSession(widget_t * p) line = director->list->list[i]; if (strstr(line, ".sav") != NULL) { - addToWidgetSelect(p, line); + select_add(p, line); } } - destroyDirector(director); + director_destroy(director); } static void hotkey_escape() { - setScreen("mainMenu"); + screen_set("mainMenu"); } -void startScreenGameType() +void screen_startGameType() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif - setWidgetChoiceStatus(check_none, TRUE); - setWidgetChoiceStatus(check_server, FALSE); - setWidgetChoiceStatus(check_client, FALSE); - setWidgetChoiceStatus(check_load_session, FALSE); + choiceGroup_set_status(check_none, TRUE); + choiceGroup_set_status(check_server, FALSE); + choiceGroup_set_status(check_client, FALSE); + choiceGroup_set_status(check_load_session, FALSE); loadSession(selectSession); - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); } -void drawScreenGameType() +void gameType_draw() { int i; - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); for (i = 0; i < listChoiceGroup->count; i++) { widget_t *this; this = (widget_t *) listChoiceGroup->list[i]; - drawWidgetChoicegroup(this); + choiceGroup_draw(this); } - drawWidgetLabel(label_none); - drawWidgetLabel(label_server); - drawWidgetLabel(label_client); - drawWidgetLabel(label_load_session); + label_draw(label_none); + label_draw(label_server); + label_draw(label_client); + label_draw(label_load_session); - if (getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE) { - drawWidgetLabel(label_port); - drawWidgetTextfield(textfield_port); - drawWidgetLabel(label_ip); - drawWidgetTextfield(textfield_ip); + if (choiceGroup_get_status(check_server) == TRUE || choiceGroup_get_status(check_client) == TRUE) { + label_draw(label_port); + textField_draw(textfield_port); + label_draw(label_ip); + textField_draw(textfield_ip); } - if (getWidgetChoiceStatus(check_load_session) == TRUE) { - drawWidgetLabel(label_session); - drawWidgetSelect(selectSession); + if (choiceGroup_get_status(check_load_session) == TRUE) { + label_draw(label_session); + select_draw(selectSession); } #if 0 if (check_server->status == TRUE) { - setSettingIP(getParamElse("--ip", "127.0.0.1")); - setSettingPort(atoi(getParamElse("--port", "2200"))); + gameType_set_ip(getParamElse("--ip", "127.0.0.1")); + gameType_set_port(atoi(getParamElse("--port", "2200"))); } #endif - if (getWidgetChoiceStatus(check_client) == TRUE) - drawWidgetButton(button_browser); + if (choiceGroup_get_status(check_client) == TRUE) + button_draw(button_browser); - drawWidgetButton(button_back); - drawWidgetButton(button_play); + button_draw(button_back); + button_draw(button_play); } -void eventScreenGameType() +void gameType_event() { int i; @@ -156,28 +156,28 @@ void eventScreenGameType() widget_t *this; this = (widget_t *) listChoiceGroup->list[i]; - eventWidgetChoicegroup(this); + choiceGroup_event(this); } - if (getWidgetChoiceStatus(check_server) == TRUE || getWidgetChoiceStatus(check_client) == TRUE) { - eventWidgetTextfield(textfield_ip); - eventWidgetTextfield(textfield_port); + if (choiceGroup_get_status(check_server) == TRUE || choiceGroup_get_status(check_client) == TRUE) { + textField_event(textfield_ip); + textField_event(textfield_port); } - if (getWidgetChoiceStatus(check_load_session) == TRUE) { - eventWidgetSelect(selectSession); + if (choiceGroup_get_status(check_load_session) == TRUE) { + select_event(selectSession); } - eventWidgetButton(button_back); - eventWidgetButton(button_play); + button_event(button_back); + button_event(button_play); - if (getWidgetChoiceStatus(check_client) == TRUE) - eventWidgetButton(button_browser); + if (choiceGroup_get_status(check_client) == TRUE) + button_event(button_browser); } void stopScreenGameType() { - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); } static void eventWidget(void *p) @@ -187,110 +187,110 @@ static void eventWidget(void *p) button = (widget_t *) (p); if (button == button_back) { - setScreen("mainMenu"); + screen_set("mainMenu"); } if (button == button_play) { char *str; - str = getGemeTypeLoadSession(); + str = gameType_load_session(); if (str != NULL) { - setScreen("world"); + screen_set("world"); return; } - if (getSettingGameType() == NET_GAME_TYPE_CLIENT) { - setScreen("downArena"); - //setScreen("world"); + if (publicServer_get_settingGameType() == NET_GAME_TYPE_CLIENT) { + screen_set("downArena"); + //screen_set("world"); } else { - setScreen("chiceArena"); + screen_set("chiceArena"); } } if (button == button_browser) { - setScreen("browser"); + screen_set("browser"); } } -void initScreenGameType() +void gameType_init() { image_t *image; - image = getImage(IMAGE_GROUP_BASE, "screen_main"); - image_backgorund = newWidgetImage(0, 0, image); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = wid_image_new(0, 0, image); - button_back = newWidgetButton(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); - button_play = newWidgetButton(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); - button_browser = newWidgetButton(_("browser"), 300, 345, eventWidget); + button_back = button_new(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); + button_play = button_new(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); + button_browser = button_new(_("browser"), 300, 345, eventWidget); - listChoiceGroup = newList(); - check_none = newWidgetChoicegroup(100, 150, FALSE, listChoiceGroup, eventWidget); - check_server = newWidgetChoicegroup(100, 200, FALSE, listChoiceGroup, eventWidget); - check_client = newWidgetChoicegroup(100, 250, FALSE, listChoiceGroup, eventWidget); - check_load_session = newWidgetChoicegroup(100, 300, FALSE, listChoiceGroup, eventWidget); + listChoiceGroup = list_new(); + check_none = choiceGroup_new(100, 150, FALSE, listChoiceGroup, eventWidget); + check_server = choiceGroup_new(100, 200, FALSE, listChoiceGroup, eventWidget); + check_client = choiceGroup_new(100, 250, FALSE, listChoiceGroup, eventWidget); + check_load_session = choiceGroup_new(100, 300, FALSE, listChoiceGroup, eventWidget); if (isParamFlag("--server")) { - setWidgetChoiceStatus(check_server, TRUE); + choiceGroup_set_status(check_server, TRUE); } else if (isParamFlag("--client")) { - setWidgetChoiceStatus(check_client, TRUE); + choiceGroup_set_status(check_client, TRUE); } else { - setWidgetChoiceStatus(check_none, TRUE); + choiceGroup_set_status(check_none, TRUE); } - label_none = newWidgetLabel(_("Local game"), 130, 145, WIDGET_LABEL_LEFT); - label_server = newWidgetLabel(_("Set up a server"), 130, 195, WIDGET_LABEL_LEFT); - label_client = newWidgetLabel(_("Network game"), 130, 245, WIDGET_LABEL_LEFT); - label_load_session = newWidgetLabel("load session", 130, 295, WIDGET_LABEL_LEFT); + label_none = label_new(_("Local game"), 130, 145, WIDGET_LABEL_LEFT); + label_server = label_new(_("Set up a server"), 130, 195, WIDGET_LABEL_LEFT); + label_client = label_new(_("Network game"), 130, 245, WIDGET_LABEL_LEFT); + label_load_session = label_new("load session", 130, 295, WIDGET_LABEL_LEFT); - label_ip = newWidgetLabel(_("IP"), 300, 145, WIDGET_LABEL_LEFT); - label_port = newWidgetLabel(_("port"), 300, 245, WIDGET_LABEL_LEFT); - label_session = newWidgetLabel("load session :", 300, 145, WIDGET_LABEL_LEFT); + label_ip = label_new(_("IP"), 300, 145, WIDGET_LABEL_LEFT); + label_port = label_new(_("port"), 300, 245, WIDGET_LABEL_LEFT); + label_session = label_new("load session :", 300, 145, WIDGET_LABEL_LEFT); - textfield_ip = newWidgetTextfield(getParamElse("--ip", "127.0.0.1"), + textfield_ip = textField_new(getParamElse("--ip", "127.0.0.1"), WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN, 300, 180); - textfield_port = newWidgetTextfield(getParamElse("--port", "6800"), + textfield_port = textField_new(getParamElse("--port", "6800"), WIDGET_TEXTFIELD_FILTER_NUM, 300, 280); - selectSession = newWidgetSelect(300, 185, eventWidget); + selectSession = select_new(300, 185, eventWidget); - registerScreen( newScreen("gameType", startScreenGameType, eventScreenGameType, - drawScreenGameType, stopScreenGameType)); + screen_register( screen_new("gameType", screen_startGameType, gameType_event, + gameType_draw, stopScreenGameType)); } int setSettingGameType(int status) { if (status == NET_GAME_TYPE_NONE) { - setWidgetChoiceStatus(check_none, TRUE); + choiceGroup_set_status(check_none, TRUE); return 0; } if (status == NET_GAME_TYPE_SERVER) { - setWidgetChoiceStatus(check_server, TRUE); + choiceGroup_set_status(check_server, TRUE); return 0; } if (status == NET_GAME_TYPE_CLIENT) { - setWidgetChoiceStatus(check_client, TRUE); + choiceGroup_set_status(check_client, TRUE); return 0; } return -1; } -int getSettingGameType() +int publicServer_get_settingGameType() { - if (getWidgetChoiceStatus(check_none) == TRUE || getWidgetChoiceStatus(check_load_session) == TRUE) { + if (choiceGroup_get_status(check_none) == TRUE || choiceGroup_get_status(check_load_session) == TRUE) { return NET_GAME_TYPE_NONE; } - if (getWidgetChoiceStatus(check_server) == TRUE) { + if (choiceGroup_get_status(check_server) == TRUE) { return NET_GAME_TYPE_SERVER; } - if (getWidgetChoiceStatus(check_client) == TRUE) { + if (choiceGroup_get_status(check_client) == TRUE) { return NET_GAME_TYPE_CLIENT; } @@ -299,52 +299,52 @@ int getSettingGameType() return -1; } -char *getGemeTypeLoadSession() +char *gameType_load_session() { - if (getWidgetChoiceStatus(check_load_session) == TRUE) { - return getWidgetSelectItem(selectSession); + if (choiceGroup_get_status(check_load_session) == TRUE) { + return select_get_item(selectSession); } return NULL; } -int setSettingIP(char *address) +int gameType_set_ip(char *address) { char str[STR_SIZE]; strcpy(str, address); - setWidgetTextFiledText(textfield_ip, str); + textField_set_text(textfield_ip, str); return 1; } -char *getSettingIP() +char *publicServer_get_settingIP() { - return getTextFromWidgetTextfield(textfield_ip); + return textField_get_text(textfield_ip); } -int setSettingPort(int port) +int gameType_set_port(int port) { char str[STR_SIZE]; sprintf(str, "%d", port); - setWidgetTextFiledText(textfield_port, str); + textField_set_text(textfield_port, str); return 0; } -int getSettingPort() +int publicServer_get_settingPort() { - return atoi(getTextFromWidgetTextfield(textfield_port)); + return atoi(textField_get_text(textfield_port)); } -int getSettingProto() +int publicServer_get_settingProto() { - if (strstr(getTextFromWidgetTextfield(textfield_ip), ".") != NULL) { + if (strstr(textField_get_text(textfield_ip), ".") != NULL) { return PROTO_UDPv4; } - if (strstr(getTextFromWidgetTextfield(textfield_ip), ":") != NULL) { + if (strstr(textField_get_text(textfield_ip), ":") != NULL) { return PROTO_UDPv6; } @@ -353,32 +353,32 @@ int getSettingProto() return -1; } -void quitScreenGameType() +void gameType_quit() { - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyWidgetLabel(label_none); - destroyWidgetLabel(label_server); - destroyWidgetLabel(label_client); - destroyWidgetLabel(label_load_session); + label_destroy(label_none); + label_destroy(label_server); + label_destroy(label_client); + label_destroy(label_load_session); - destroyWidgetLabel(label_ip); - destroyWidgetLabel(label_port); - destroyWidgetLabel(label_session); + label_destroy(label_ip); + label_destroy(label_port); + label_destroy(label_session); - destroyWidgetTextfield(textfield_ip); - destroyWidgetTextfield(textfield_port); + textField_destroy(textfield_ip); + textField_destroy(textfield_port); - destroyWidgetSelect(selectSession); + select_destroy(selectSession); - destroyWidgetButton(button_back); - destroyWidgetButton(button_play); - destroyWidgetButton(button_browser); + button_destroy(button_back); + button_destroy(button_play); + button_destroy(button_browser); - destroyWidgetChoicegroup(check_none); - destroyWidgetChoicegroup(check_server); - destroyWidgetChoicegroup(check_client); - destroyWidgetChoicegroup(check_load_session); + choiceGroup_destroy(check_none); + choiceGroup_destroy(check_server); + choiceGroup_destroy(check_client); + choiceGroup_destroy(check_load_session); - destroyList(listChoiceGroup); + list_destroy(listChoiceGroup); } diff --git a/src/screen/gameType.h b/src/screen/gameType.h index 2c836fc..a2b4457 100644 --- a/src/screen/gameType.h +++ b/src/screen/gameType.h @@ -5,17 +5,17 @@ # include "main.h" -extern void drawScreenGameType(); -extern void eventScreenGameType(); -extern void initScreenGameType(); +extern void gameType_draw(); +extern void gameType_event(); +extern void gameType_init(); extern int setSettingGameType(int status); -extern int getSettingGameType(); -extern char *getGemeTypeLoadSession(); -extern int setSettingIP(char *address); -extern char *getSettingIP(); -extern int setSettingPort(int port); -extern int getSettingPort(); -extern int getSettingProto(); -extern void quitScreenGameType(); +extern int publicServer_get_settingGameType(); +extern char *gameType_load_session(); +extern int gameType_set_ip(char *address); +extern char *publicServer_get_settingIP(); +extern int gameType_set_port(int port); +extern int publicServer_get_settingPort(); +extern int publicServer_get_settingProto(); +extern void gameType_quit(); #endif diff --git a/src/screen/mainMenu.c b/src/screen/mainMenu.c index 56ebd4c..d9df377 100644 --- a/src/screen/mainMenu.c +++ b/src/screen/mainMenu.c @@ -34,41 +34,41 @@ static widget_t *button_end; static void hotkey_escape() { - quitGame(); + game_quit(); } -void startScreenMainMenu() +void mainMenu_start() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); } -void drawScreenMainMenu() +void mainMenu_draw() { - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); - drawWidgetButton(button_play); - drawWidgetButton(button_setting); - drawWidgetButton(button_table); - drawWidgetButton(button_credits); - drawWidgetButton(button_end); + button_draw(button_play); + button_draw(button_setting); + button_draw(button_table); + button_draw(button_credits); + button_draw(button_end); } -void eventScreenMainMenu() +void mainMenu_event() { - eventWidgetButton(button_play); - eventWidgetButton(button_setting); - eventWidgetButton(button_table); - eventWidgetButton(button_credits); - eventWidgetButton(button_end); + button_event(button_play); + button_event(button_setting); + button_event(button_table); + button_event(button_credits); + button_event(button_end); } -void stopScreenMainMenu() +void mainMenu_stop() { - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); } static void eventWidget(void *p) @@ -78,56 +78,56 @@ static void eventWidget(void *p) button = (widget_t *) (p); if (button == button_play) { - setScreen("gameType"); + screen_set("gameType"); } if (button == button_setting) { - setScreen("setting"); + screen_set("setting"); } if (button == button_table) { - setScreen("table"); + screen_set("table"); } if (button == button_credits) { - setScreen("credits"); + screen_set("credits"); } if (button == button_end) { - quitGame(); + game_quit(); } } -void initScreenMainMenu() +void mainMenu_init() { image_t *image; image = - addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_main", + image_add("screen_main.png", IMAGE_NO_ALPHA, "screen_main", IMAGE_GROUP_BASE); - image_backgorund = newWidgetImage(0, 0, image); + image_backgorund = wid_image_new(0, 0, image); - button_play = newWidgetButton(_("Start game"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 200, eventWidget); - button_setting = newWidgetButton(_("Settings"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 250, eventWidget); - button_table = newWidgetButton(_("Highscore"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 300, eventWidget); - button_credits = newWidgetButton(_("Credits"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 350, eventWidget); - button_end = newWidgetButton(_("Quit game"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 400, eventWidget); + button_play = button_new(_("Start game"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 200, eventWidget); + button_setting = button_new(_("Settings"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 250, eventWidget); + button_table = button_new(_("Highscore"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 300, eventWidget); + button_credits = button_new(_("Credits"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 350, eventWidget); + button_end = button_new(_("Quit game"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 400, eventWidget); #ifndef NO_SOUND - addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE); + music_add("menu.ogg", "menu", MUSIC_GROUP_BASE); #endif - registerScreen( newScreen("mainMenu", startScreenMainMenu, eventScreenMainMenu, - drawScreenMainMenu, stopScreenMainMenu)); + screen_register( screen_new("mainMenu", mainMenu_start, mainMenu_event, + mainMenu_draw, mainMenu_stop)); } -void quitScreenMainMenu() +void mainMenu_quit() { - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyWidgetButton(button_play); - destroyWidgetButton(button_setting); - destroyWidgetButton(button_table); - destroyWidgetButton(button_credits); - destroyWidgetButton(button_end); + button_destroy(button_play); + button_destroy(button_setting); + button_destroy(button_table); + button_destroy(button_credits); + button_destroy(button_end); } diff --git a/src/screen/mainMenu.h b/src/screen/mainMenu.h index ecb369b..84048a1 100644 --- a/src/screen/mainMenu.h +++ b/src/screen/mainMenu.h @@ -5,11 +5,11 @@ # include "main.h" -extern void startScreenMainMenu(); -extern void drawScreenMainMenu(); -extern void eventScreenMainMenu(); -extern void stopScreenMainMenu(); -extern void initScreenMainMenu(); -extern void quitScreenMainMenu(); +extern void mainMenu_start(); +extern void mainMenu_draw(); +extern void mainMenu_event(); +extern void mainMenu_stop(); +extern void mainMenu_init(); +extern void mainMenu_quit(); #endif diff --git a/src/screen/setting.c b/src/screen/setting.c index 1895ec2..d5c5c1a 100644 --- a/src/screen/setting.c +++ b/src/screen/setting.c @@ -81,107 +81,107 @@ static textFile_t *configFile; static void hotkey_escape() { - setScreen("mainMenu"); + screen_set("mainMenu"); } -void startScreenSetting() +void screen_startSetting() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); } -void drawScreenSetting() +void setting_draw() { int i; - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); - drawWidgetLabel(label_count_round); - drawWidgetLabel(label_name_player1); - drawWidgetLabel(label_ai); + label_draw(label_count_round); + label_draw(label_name_player1); + label_draw(label_ai); #ifndef NO_SOUND - drawWidgetLabel(label_music); - drawWidgetLabel(label_sound); + label_draw(label_music); + label_draw(label_sound); #endif - drawWidgetTextfield(textfield_count_cound); - drawWidgetTextfield(textfield_name_player1); + textField_draw(textfield_count_cound); + textField_draw(textfield_name_player1); - if (getWidgetCheckStatus(check_ai) == FALSE) { - drawWidgetLabel(label_name_player2); - drawWidgetTextfield(textfield_name_player2); + if (check_get_status(check_ai) == FALSE) { + label_draw(label_name_player2); + textField_draw(textfield_name_player2); } - drawWidgetImage(image_gun_dual_revolver); - drawWidgetImage(image_gun_scatter); - drawWidgetImage(image_gun_tommy); - drawWidgetImage(image_gun_lasser); - drawWidgetImage(image_gun_mine); - drawWidgetImage(image_gun_bombball); + wid_image_draw(image_gun_dual_revolver); + wid_image_draw(image_gun_scatter); + wid_image_draw(image_gun_tommy); + wid_image_draw(image_gun_lasser); + wid_image_draw(image_gun_mine); + wid_image_draw(image_gun_bombball); - drawWidgetImage(image_bonus_speed); - drawWidgetImage(image_bonus_shot); - drawWidgetImage(image_bonus_teleport); - drawWidgetImage(image_bonus_ghost); - drawWidgetImage(image_bonus_4x); - drawWidgetImage(image_bonus_hidden); + wid_image_draw(image_bonus_speed); + wid_image_draw(image_bonus_shot); + wid_image_draw(image_bonus_teleport); + wid_image_draw(image_bonus_ghost); + wid_image_draw(image_bonus_4x); + wid_image_draw(image_bonus_hidden); #ifndef NO_SOUND - drawWidgetCheck(check_music); - drawWidgetCheck(check_sound); + check_draw(check_music); + check_draw(check_sound); #endif for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) { - drawWidgetCheck(check[i]); + check_draw(check[i]); } for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) { - drawWidgetCheck(check[i]); + check_draw(check[i]); } - drawWidgetCheck(check_ai); + check_draw(check_ai); - drawWidgetButton(button_back); - drawWidgetButton(button_keys); + button_draw(button_back); + button_draw(button_keys); } -void eventScreenSetting() +void setting_event() { int i; - eventWidgetTextfield(textfield_count_cound); - eventWidgetTextfield(textfield_name_player1); + textField_event(textfield_count_cound); + textField_event(textfield_name_player1); - if (getWidgetCheckStatus(check_ai) == FALSE) { - eventWidgetTextfield(textfield_name_player2); + if (check_get_status(check_ai) == FALSE) { + textField_event(textfield_name_player2); } #ifndef NO_SOUND - eventWidgetCheck(check_music); - eventWidgetCheck(check_sound); + check_event(check_music); + check_event(check_sound); #endif for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) { - eventWidgetCheck(check[i]); + check_event(check[i]); } for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) { - eventWidgetCheck(check[i]); + check_event(check[i]); } - eventWidgetCheck(check_ai); + check_event(check_ai); - eventWidgetButton(button_back); - eventWidgetButton(button_keys); + button_event(button_back); + button_event(button_keys); } void stopScreenSetting() { - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); } static void eventWidget(void *p) @@ -193,20 +193,20 @@ static void eventWidget(void *p) my_check = (widget_t *) (p); if (my_button == button_back) { - setScreen("mainMenu"); + screen_set("mainMenu"); } if (my_button == button_keys) { - setScreen("settingKeys"); + screen_set("settingKeys"); } #ifndef NO_SOUND if (my_check == check_music) { - setMusicActive(getWidgetCheckStatus(check_music)); + music_set_active(check_get_status(check_music)); } if (my_check == check_sound) { - setSoundActive(getWidgetCheckStatus(check_sound)); + sound_set_active(check_get_status(check_sound)); } #endif } @@ -216,15 +216,15 @@ static void initSettingFile() char path[STR_PATH_SIZE]; char val[STR_SIZE]; - sprintf(path, "%s/tuxanci.conf", getHomeDirector()); + sprintf(path, "%s/tuxanci.conf", homeDirector_get()); - configFile = loadTextFile(path); + configFile = textFile_load(path); if (configFile == NULL) { fprintf(stderr, _("I am unable to load: \"%s\"!\n"), path); fprintf(stderr, _("Creating: \"%s\"\n"), path); - configFile = newTextFile(path); + configFile = textFile_new(path); } if (configFile == NULL) { @@ -233,59 +233,59 @@ static void initSettingFile() } loadValueFromConfigFile(configFile, "COUNT_ROUND", val, STR_SIZE, "15"); - setWidgetTextFiledText(textfield_count_cound, val); + textField_set_text(textfield_count_cound, val); loadValueFromConfigFile(configFile, "NAME_PLAYER_RIGHT", val, STR_SIZE, NAME_PLAYER_RIGHT); - setWidgetTextFiledText(textfield_name_player1, val); + textField_set_text(textfield_name_player1, val); loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE, NAME_PLAYER_LEFT); - setWidgetTextFiledText(textfield_name_player2, val); + textField_set_text(textfield_name_player2, val); loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[GUN_DUAL_SIMPLE], isYesOrNO(val)); + check_set_status(check[GUN_DUAL_SIMPLE], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[GUN_SCATTER], isYesOrNO(val)); + check_set_status(check[GUN_SCATTER], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_TOMMY", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[GUN_TOMMY], isYesOrNO(val)); + check_set_status(check[GUN_TOMMY], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_LASSER", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[GUN_LASSER], isYesOrNO(val)); + check_set_status(check[GUN_LASSER], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_MINE", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[GUN_MINE], isYesOrNO(val)); + check_set_status(check[GUN_MINE], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_BOMBBALL", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[GUN_BOMBBALL], isYesOrNO(val)); + check_set_status(check[GUN_BOMBBALL], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_SPEED", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[BONUS_SPEED], isYesOrNO(val)); + check_set_status(check[BONUS_SPEED], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_SHOT", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[BONUS_SHOT], isYesOrNO(val)); + check_set_status(check[BONUS_SHOT], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[BONUS_TELEPORT], isYesOrNO(val)); + check_set_status(check[BONUS_TELEPORT], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_GHOST", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[BONUS_GHOST], isYesOrNO(val)); + check_set_status(check[BONUS_GHOST], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_4X", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[BONUS_4X], isYesOrNO(val)); + check_set_status(check[BONUS_4X], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_HIDDEN", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check[BONUS_HIDDEN], isYesOrNO(val)); + check_set_status(check[BONUS_HIDDEN], isYesOrNO(val)); loadValueFromConfigFile(configFile, "AI", val, STR_SIZE, "NO"); - setWidgetCheckStatus(check_ai, isYesOrNO(val)); + check_set_status(check_ai, isYesOrNO(val)); #ifndef NO_SOUND loadValueFromConfigFile(configFile, "MUSIC", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check_music, isYesOrNO(val)); + check_set_status(check_music, isYesOrNO(val)); loadValueFromConfigFile(configFile, "SOUND", val, STR_SIZE, "YES"); - setWidgetCheckStatus(check_sound, isYesOrNO(val)); + check_set_status(check_sound, isYesOrNO(val)); #endif loadValueFromConfigFile(configFile, "ARENA", val, STR_SIZE, "FAGN"); - setChoiceArena(getArenaFileFormNetName(val)); + choiceArena_set(arenaFile_get_file_format_net_name(val)); - saveTextFile(configFile); + textFile_save(configFile); } static void saveAndDestroyConfigFile() @@ -295,84 +295,84 @@ static void saveAndDestroyConfigFile() return; } - setValueInConfigFile(configFile, "COUNT_ROUND", getTextFromWidgetTextfield(textfield_count_cound)); - setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", getTextFromWidgetTextfield(textfield_name_player1)); - setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", getTextFromWidgetTextfield(textfield_name_player2)); - setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE", getYesOrNo(getWidgetCheckStatus(check[GUN_DUAL_SIMPLE]))); - setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(getWidgetCheckStatus(check[GUN_SCATTER]))); - setValueInConfigFile(configFile, "GUN_TOMMY", getYesOrNo(getWidgetCheckStatus(check[GUN_TOMMY]))); - setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(getWidgetCheckStatus(check[GUN_LASSER]))); - setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(getWidgetCheckStatus(check[GUN_MINE]))); - setValueInConfigFile(configFile, "GUN_BOMBBALL", getYesOrNo(getWidgetCheckStatus(check[GUN_BOMBBALL]))); - setValueInConfigFile(configFile, "BONUS_SPEED", getYesOrNo(getWidgetCheckStatus(check[BONUS_SPEED]))); - setValueInConfigFile(configFile, "BONUS_SHOT", getYesOrNo(getWidgetCheckStatus(check[BONUS_SHOT]))); - setValueInConfigFile(configFile, "BONUS_TELEPORT", getYesOrNo(getWidgetCheckStatus (check[BONUS_TELEPORT]))); - setValueInConfigFile(configFile, "BONUS_GHOST", getYesOrNo(getWidgetCheckStatus(check[BONUS_GHOST]))); - setValueInConfigFile(configFile, "BONUS_4X", getYesOrNo(getWidgetCheckStatus(check[BONUS_4X]))); - setValueInConfigFile(configFile, "BONUS_HIDDEN", getYesOrNo(getWidgetCheckStatus(check[BONUS_HIDDEN]))); - setValueInConfigFile(configFile, "AI", getYesOrNo(getWidgetCheckStatus(check_ai))); + setValueInConfigFile(configFile, "COUNT_ROUND", textField_get_text(textfield_count_cound)); + setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", textField_get_text(textfield_name_player1)); + setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", textField_get_text(textfield_name_player2)); + setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE", getYesOrNo(check_get_status(check[GUN_DUAL_SIMPLE]))); + setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(check_get_status(check[GUN_SCATTER]))); + setValueInConfigFile(configFile, "GUN_TOMMY", getYesOrNo(check_get_status(check[GUN_TOMMY]))); + setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(check_get_status(check[GUN_LASSER]))); + setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(check_get_status(check[GUN_MINE]))); + setValueInConfigFile(configFile, "GUN_BOMBBALL", getYesOrNo(check_get_status(check[GUN_BOMBBALL]))); + setValueInConfigFile(configFile, "BONUS_SPEED", getYesOrNo(check_get_status(check[BONUS_SPEED]))); + setValueInConfigFile(configFile, "BONUS_SHOT", getYesOrNo(check_get_status(check[BONUS_SHOT]))); + setValueInConfigFile(configFile, "BONUS_TELEPORT", getYesOrNo(check_get_status (check[BONUS_TELEPORT]))); + setValueInConfigFile(configFile, "BONUS_GHOST", getYesOrNo(check_get_status(check[BONUS_GHOST]))); + setValueInConfigFile(configFile, "BONUS_4X", getYesOrNo(check_get_status(check[BONUS_4X]))); + setValueInConfigFile(configFile, "BONUS_HIDDEN", getYesOrNo(check_get_status(check[BONUS_HIDDEN]))); + setValueInConfigFile(configFile, "AI", getYesOrNo(check_get_status(check_ai))); #ifndef NO_SOUND - setValueInConfigFile(configFile, "MUSIC", getYesOrNo(getWidgetCheckStatus(check_music))); - setValueInConfigFile(configFile, "SOUND", getYesOrNo(getWidgetCheckStatus(check_sound))); + setValueInConfigFile(configFile, "MUSIC", getYesOrNo(check_get_status(check_music))); + setValueInConfigFile(configFile, "SOUND", getYesOrNo(check_get_status(check_sound))); #endif - if( getChoiceArena() != NULL ) + if( choiceArena_get() != NULL ) { - setValueInConfigFile(configFile, "ARENA", getArenaNetName(getChoiceArena())); + setValueInConfigFile(configFile, "ARENA", arenaFile_get_net_name(choiceArena_get())); } //TODO - saveTextFile(configFile); - destroyTextFile(configFile); + textFile_save(configFile); + textFile_destroy(configFile); } -void initScreenSetting() +void setting_init() { image_t *image; int i; - image = getImage(IMAGE_GROUP_BASE, "screen_main"); - image_backgorund = newWidgetImage(0, 0, image); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = wid_image_new(0, 0, image); - button_back = newWidgetButton(_("back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); + button_back = button_new(_("back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); - button_keys = newWidgetButton(_("controls"), WINDOW_SIZE_X - 200, + button_keys = button_new(_("controls"), WINDOW_SIZE_X - 200, button_back->y - WIDGET_BUTTON_HEIGHT - 10, eventWidget); #ifndef NO_SOUND - label_music = newWidgetLabel(_("Music:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); + label_music = label_new(_("Music:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); - check_music = newWidgetCheck(label_music->x + label_music->w + 10, - WINDOW_SIZE_Y - 80, isMusicActive(), eventWidget); - label_sound = newWidgetLabel(_("Sound:"), check_music->x + WIDGET_CHECK_WIDTH + 10, + check_music = check_new(label_music->x + label_music->w + 10, + WINDOW_SIZE_Y - 80, music_is_active(), eventWidget); + label_sound = label_new(_("Sound:"), check_music->x + WIDGET_CHECK_WIDTH + 10, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); - check_sound = newWidgetCheck(label_sound->x + label_sound->w + 10, - WINDOW_SIZE_Y - 80, isSoundActive(), eventWidget); + check_sound = check_new(label_sound->x + label_sound->w + 10, + WINDOW_SIZE_Y - 80, sound_is_active(), eventWidget); - label_ai = newWidgetLabel(_("AI:"), check_sound->x + WIDGET_CHECK_WIDTH + 10, + label_ai = label_new(_("AI:"), check_sound->x + WIDGET_CHECK_WIDTH + 10, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); #else - label_ai = newWidgetLabel(_("AI:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); + label_ai = label_new(_("AI:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); #endif - check_ai = newWidgetCheck(label_ai->x + label_ai->w + 10, WINDOW_SIZE_Y - 80, FALSE, eventWidget); + check_ai = check_new(label_ai->x + label_ai->w + 10, WINDOW_SIZE_Y - 80, FALSE, eventWidget); - label_count_round = newWidgetLabel(_("No. of rounds:"), 100, WINDOW_SIZE_Y - 200, WIDGET_LABEL_LEFT); - label_name_player1 = newWidgetLabel(_("Player 1:"), 100, WINDOW_SIZE_Y - 160, WIDGET_LABEL_LEFT); - label_name_player2 = newWidgetLabel(_("Player 2:"), 100, WINDOW_SIZE_Y - 120, WIDGET_LABEL_LEFT); + label_count_round = label_new(_("No. of rounds:"), 100, WINDOW_SIZE_Y - 200, WIDGET_LABEL_LEFT); + label_name_player1 = label_new(_("Player 1:"), 100, WINDOW_SIZE_Y - 160, WIDGET_LABEL_LEFT); + label_name_player2 = label_new(_("Player 2:"), 100, WINDOW_SIZE_Y - 120, WIDGET_LABEL_LEFT); - textfield_count_cound = newWidgetTextfield(getParamElse("--count", "15"), + textfield_count_cound = textField_new(getParamElse("--count", "15"), WIDGET_TEXTFIELD_FILTER_NUM, 110 + label_count_round->w, WINDOW_SIZE_Y - 200); - textfield_name_player1 = newWidgetTextfield(getParamElse("--name1", NAME_PLAYER_RIGHT), + textfield_name_player1 = textField_new(getParamElse("--name1", NAME_PLAYER_RIGHT), WIDGET_TEXTFIELD_FILTER_ALPHANUM, 110 + label_count_round->w, WINDOW_SIZE_Y - 160); - textfield_name_player2 = newWidgetTextfield(getParamElse("--name2", NAME_PLAYER_LEFT), + textfield_name_player2 = textField_new(getParamElse("--name2", NAME_PLAYER_LEFT), WIDGET_TEXTFIELD_FILTER_ALPHANUM, 110 + label_count_round->w, WINDOW_SIZE_Y - 120); @@ -390,7 +390,7 @@ void initScreenSetting() y = 200 + (i - GUN_LASSER) * 50; } - check[i] = newWidgetCheck(x, y, TRUE, NULL); + check[i] = check_new(x, y, TRUE, NULL); } for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) { @@ -407,24 +407,24 @@ void initScreenSetting() y = 200 + (i - BONUS_GHOST) * 50; } - check[i] = newWidgetCheck(x, y, TRUE, NULL); + check[i] = check_new(x, y, TRUE, NULL); } - image_gun_dual_revolver = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_dual")); - image_gun_scatter = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_scatter")); - image_gun_tommy = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_tommy")); - image_gun_lasser = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 200,getImage(IMAGE_GROUP_BASE, "panel_lasser")); - image_gun_mine = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_mine")); - image_gun_bombball = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_bombball")); - image_bonus_speed = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_speed"));; - image_bonus_shot = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_shot"));; - image_bonus_teleport = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_teleport"));; - image_bonus_ghost = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_ghost"));; - image_bonus_4x = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_4x"));; - image_bonus_hidden = newWidgetImage(580 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_hidden"));; - - registerScreen( newScreen("setting", startScreenSetting, eventScreenSetting, - drawScreenSetting, stopScreenSetting)); + image_gun_dual_revolver = wid_image_new(110 + WIDGET_CHECK_WIDTH, 200, image_get(IMAGE_GROUP_BASE, "panel_dual")); + image_gun_scatter = wid_image_new(110 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_scatter")); + image_gun_tommy = wid_image_new(110 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_tommy")); + image_gun_lasser = wid_image_new(260 + WIDGET_CHECK_WIDTH, 200,image_get(IMAGE_GROUP_BASE, "panel_lasser")); + image_gun_mine = wid_image_new(260 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_mine")); + image_gun_bombball = wid_image_new(260 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_bombball")); + image_bonus_speed = wid_image_new(430 + WIDGET_CHECK_WIDTH, 200, image_get(IMAGE_GROUP_BASE, "panel_speed"));; + image_bonus_shot = wid_image_new(430 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_shot"));; + image_bonus_teleport = wid_image_new(430 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_teleport"));; + image_bonus_ghost = wid_image_new(580 + WIDGET_CHECK_WIDTH, 200, image_get(IMAGE_GROUP_BASE, "panel_ghost"));; + image_bonus_4x = wid_image_new(580 + WIDGET_CHECK_WIDTH, 250, image_get(IMAGE_GROUP_BASE, "panel_4x"));; + image_bonus_hidden = wid_image_new(580 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_hidden"));; + + screen_register( screen_new("setting", screen_startSetting, setting_event, + setting_draw, stopScreenSetting)); initSettingFile(); @@ -434,42 +434,42 @@ void initScreenSetting() #endif } -void getSettingNameRight(char *s) +void publicServer_get_settingNameRight(char *s) { - strcpy(s, getTextFromWidgetTextfield(textfield_name_player1)); + strcpy(s, textField_get_text(textfield_name_player1)); } -void getSettingNameLeft(char *s) +void publicServer_get_settingNameLeft(char *s) { - if (getWidgetCheckStatus(check_ai)) { + if (check_get_status(check_ai)) { strcpy(s, NAME_AI); } else { - strcpy(s, getTextFromWidgetTextfield(textfield_name_player2)); + strcpy(s, textField_get_text(textfield_name_player2)); } } -void getSettingCountRound(int *n) +void publicServer_get_settingCountRound(int *n) { - *n = atoi(getTextFromWidgetTextfield(textfield_count_cound)); + *n = atoi(textField_get_text(textfield_count_cound)); } -bool_t isSettingAI() +bool_t setting_is_ai() { - return getWidgetCheckStatus(check_ai); + return check_get_status(check_ai); } -bool_t isSettingAnyItem() +bool_t setting_is_any_item() { int i; for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) { - if (getWidgetCheckStatus(check[i]) == TRUE) { + if (check_get_status(check[i]) == TRUE) { return TRUE; } } for (i = BONUS_SPEED; i < BONUS_HIDDEN; i++) { - if (getWidgetCheckStatus(check[i]) == TRUE) { + if (check_get_status(check[i]) == TRUE) { return TRUE; } } @@ -477,62 +477,62 @@ bool_t isSettingAnyItem() return FALSE; } -bool_t isSettingItem(int item) +bool_t setting_is_item(int item) { - return getWidgetCheckStatus(check[item]); + return check_get_status(check[item]); } -void quitScreenSetting() +void setting_quit() { int i; saveAndDestroyConfigFile(); - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyWidgetLabel(label_count_round); - destroyWidgetLabel(label_name_player1); - destroyWidgetLabel(label_ai); + label_destroy(label_count_round); + label_destroy(label_name_player1); + label_destroy(label_ai); #ifndef NO_SOUND - destroyWidgetLabel(label_music); - destroyWidgetLabel(label_sound); + label_destroy(label_music); + label_destroy(label_sound); #endif - destroyWidgetLabel(label_name_player2); - destroyWidgetTextfield(textfield_name_player2); - - destroyWidgetTextfield(textfield_name_player1); - destroyWidgetTextfield(textfield_count_cound); - - destroyWidgetImage(image_gun_dual_revolver); - destroyWidgetImage(image_gun_scatter); - destroyWidgetImage(image_gun_tommy); - destroyWidgetImage(image_gun_lasser); - destroyWidgetImage(image_gun_mine); - destroyWidgetImage(image_gun_bombball); - - destroyWidgetImage(image_bonus_speed); - destroyWidgetImage(image_bonus_shot); - destroyWidgetImage(image_bonus_teleport); - destroyWidgetImage(image_bonus_ghost); - destroyWidgetImage(image_bonus_4x); - destroyWidgetImage(image_bonus_hidden); + label_destroy(label_name_player2); + textField_destroy(textfield_name_player2); + + textField_destroy(textfield_name_player1); + textField_destroy(textfield_count_cound); + + wid_image_destroy(image_gun_dual_revolver); + wid_image_destroy(image_gun_scatter); + wid_image_destroy(image_gun_tommy); + wid_image_destroy(image_gun_lasser); + wid_image_destroy(image_gun_mine); + wid_image_destroy(image_gun_bombball); + + wid_image_destroy(image_bonus_speed); + wid_image_destroy(image_bonus_shot); + wid_image_destroy(image_bonus_teleport); + wid_image_destroy(image_bonus_ghost); + wid_image_destroy(image_bonus_4x); + wid_image_destroy(image_bonus_hidden); #ifndef NO_SOUND - destroyWidgetCheck(check_music); - destroyWidgetCheck(check_sound); + check_destroy(check_music); + check_destroy(check_sound); #endif - destroyWidgetCheck(check_ai); + check_destroy(check_ai); for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) { - destroyWidgetCheck(check[i]); + check_destroy(check[i]); } for (i = BONUS_SPEED; i <= BONUS_HIDDEN; i++) { - destroyWidgetCheck(check[i]); + check_destroy(check[i]); } - destroyWidgetButton(button_back); - destroyWidgetButton(button_keys); + button_destroy(button_back); + button_destroy(button_keys); } diff --git a/src/screen/setting.h b/src/screen/setting.h index 9521cca..6c5ec16 100644 --- a/src/screen/setting.h +++ b/src/screen/setting.h @@ -9,14 +9,14 @@ # define NAME_PLAYER_RIGHT "Name1" # define NAME_PLAYER_LEFT "Name2" -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 bool_t isSettingAI(); -extern bool_t isSettingAnyItem(); -extern bool_t isSettingItem(int item); -extern void quitScreenSetting(); +extern void setting_init(); +extern void setting_draw(); +extern void setting_event(); +extern void publicServer_get_settingNameRight(char *s); +extern void publicServer_get_settingNameLeft(char *s); +extern void publicServer_get_settingCountRound(int *n); +extern bool_t setting_is_ai(); +extern bool_t setting_is_any_item(); +extern bool_t setting_is_item(int item); +extern void setting_quit(); #endif diff --git a/src/screen/settingKeys.c b/src/screen/settingKeys.c index 7813a69..2e44339 100644 --- a/src/screen/settingKeys.c +++ b/src/screen/settingKeys.c @@ -77,17 +77,17 @@ static widget_t *tux_left_keyfire_val; static void hotkey_escape()
{
- setScreen("setting");
+ screen_set("setting");
}
-void startScreenSettingKeys()
+void screen_startSettingKeys()
{
#ifndef NO_SOUND
- playMusic("menu", MUSIC_GROUP_BASE);
+ music_play("menu", MUSIC_GROUP_BASE);
#endif
- registerHotKey(SDLK_ESCAPE, hotkey_escape);
+ hotKey_register(SDLK_ESCAPE, hotkey_escape);
}
static void setKeytableFromConfigFile(textFile_t * configFile)
{
@@ -158,7 +158,7 @@ keytable[KEY_TUX_LEFT_SWITCH_WEAPON] = atoi(val); }
void
- initKeyTable()
+ keyTable_init()
{
char path[STR_PATH_SIZE];
@@ -166,9 +166,9 @@ char path[STR_PATH_SIZE]; /*
int i;
*/
- sprintf(path, "%s/keycontrol.conf", getHomeDirector());
+ sprintf(path, "%s/keycontrol.conf", homeDirector_get());
-keycontrolFile = loadTextFile(path);
+keycontrolFile = textFile_load(path);
if (keycontrolFile == NULL) {
@@ -176,7 +176,7 @@ fprintf(stderr, _("I was unable to load file: %s\n"), path); fprintf(stderr, _("I try to create file: %s\n"), path);
-keycontrolFile = newTextFile(path);
+keycontrolFile = textFile_new(path);
}
@@ -198,7 +198,7 @@ setKeytableFromConfigFile(keycontrolFile); */
}
-int getKey(int n)
+int keyTable_get_key(int n)
{
// printf("keytable[n] = %d\n", keytable[n]);
@@ -206,66 +206,66 @@ int getKey(int n) }
-void drawScreenSettingKeys()
+void settingKey_draw()
{
-drawWidgetImage(image_backgorund);
+wid_image_draw(image_backgorund);
-drawWidgetButton(button_back);
+button_draw(button_back);
// key names
- drawWidgetLabel(tux_right);
+ label_draw(tux_right);
-drawWidgetLabel(tux_left);
+label_draw(tux_left);
-drawWidgetLabel(tux_right_keyup);
+label_draw(tux_right_keyup);
-drawWidgetLabel(tux_right_keydown);
+label_draw(tux_right_keydown);
-drawWidgetLabel(tux_right_keyleft);
+label_draw(tux_right_keyleft);
-drawWidgetLabel(tux_right_keyright);
+label_draw(tux_right_keyright);
-drawWidgetLabel(tux_right_keyswitch);
+label_draw(tux_right_keyswitch);
-drawWidgetLabel(tux_right_keyfire);
+label_draw(tux_right_keyfire);
-drawWidgetLabel(tux_left_keyup);
+label_draw(tux_left_keyup);
-drawWidgetLabel(tux_left_keydown);
+label_draw(tux_left_keydown);
-drawWidgetLabel(tux_left_keyleft);
+label_draw(tux_left_keyleft);
-drawWidgetLabel(tux_left_keyright);
+label_draw(tux_left_keyright);
-drawWidgetLabel(tux_left_keyswitch);
+label_draw(tux_left_keyswitch);
-drawWidgetLabel(tux_left_keyfire);
+label_draw(tux_left_keyfire);
// key values
- drawWidgetCatchkey(tux_right_keyup_val);
+ catchKey_draw(tux_right_keyup_val);
-drawWidgetCatchkey(tux_right_keydown_val);
+catchKey_draw(tux_right_keydown_val);
-drawWidgetCatchkey(tux_right_keyleft_val);
+catchKey_draw(tux_right_keyleft_val);
-drawWidgetCatchkey(tux_right_keyright_val);
+catchKey_draw(tux_right_keyright_val);
-drawWidgetCatchkey(tux_right_keyswitch_val);
+catchKey_draw(tux_right_keyswitch_val);
-drawWidgetCatchkey(tux_right_keyfire_val);
+catchKey_draw(tux_right_keyfire_val);
-drawWidgetCatchkey(tux_left_keyup_val);
+catchKey_draw(tux_left_keyup_val);
-drawWidgetCatchkey(tux_left_keydown_val);
+catchKey_draw(tux_left_keydown_val);
-drawWidgetCatchkey(tux_left_keyleft_val);
+catchKey_draw(tux_left_keyleft_val);
-drawWidgetCatchkey(tux_left_keyright_val);
+catchKey_draw(tux_left_keyright_val);
-drawWidgetCatchkey(tux_left_keyswitch_val);
+catchKey_draw(tux_left_keyswitch_val);
-drawWidgetCatchkey(tux_left_keyfire_val);
+catchKey_draw(tux_left_keyfire_val);
}
static void
@@ -273,29 +273,29 @@ static void refreshKeytable()
{
-keytable[6] = getWidgetCatchKey(tux_left_keyup_val);
+keytable[6] = catchKey_get(tux_left_keyup_val);
-keytable[9] = getWidgetCatchKey(tux_left_keydown_val);
+keytable[9] = catchKey_get(tux_left_keydown_val);
-keytable[8] = getWidgetCatchKey(tux_left_keyleft_val);
+keytable[8] = catchKey_get(tux_left_keyleft_val);
-keytable[7] = getWidgetCatchKey(tux_left_keyright_val);
+keytable[7] = catchKey_get(tux_left_keyright_val);
-keytable[10] = getWidgetCatchKey(tux_left_keyfire_val);
+keytable[10] = catchKey_get(tux_left_keyfire_val);
-keytable[11] = getWidgetCatchKey(tux_left_keyswitch_val);
+keytable[11] = catchKey_get(tux_left_keyswitch_val);
-keytable[0] = getWidgetCatchKey(tux_right_keyup_val);
+keytable[0] = catchKey_get(tux_right_keyup_val);
-keytable[3] = getWidgetCatchKey(tux_right_keydown_val);
+keytable[3] = catchKey_get(tux_right_keydown_val);
-keytable[2] = getWidgetCatchKey(tux_right_keyleft_val);
+keytable[2] = catchKey_get(tux_right_keyleft_val);
-keytable[1] = getWidgetCatchKey(tux_right_keyright_val);
+keytable[1] = catchKey_get(tux_right_keyright_val);
-keytable[4] = getWidgetCatchKey(tux_right_keyfire_val);
+keytable[4] = catchKey_get(tux_right_keyfire_val);
-keytable[5] = getWidgetCatchKey(tux_right_keyswitch_val);
+keytable[5] = catchKey_get(tux_right_keyswitch_val);
}
static void eventWidget(void *p)
@@ -312,7 +312,7 @@ catcher = (widget_t *) (p); if (button == button_back)
-setScreen("setting");
+screen_set("setting");
//events on value
if ((catcher == tux_left_keyup_val) ||
@@ -337,253 +337,253 @@ setScreen("setting"); }
-void eventScreenSettingKeys()
+void settingKey_event()
{
-eventWidgetButton(button_back);
+button_event(button_back);
-eventWidgetCatchkey(tux_right_keyup_val);
+catchKey_event(tux_right_keyup_val);
-eventWidgetCatchkey(tux_right_keydown_val);
+catchKey_event(tux_right_keydown_val);
-eventWidgetCatchkey(tux_right_keyleft_val);
+catchKey_event(tux_right_keyleft_val);
-eventWidgetCatchkey(tux_right_keyright_val);
+catchKey_event(tux_right_keyright_val);
-eventWidgetCatchkey(tux_right_keyswitch_val);
+catchKey_event(tux_right_keyswitch_val);
-eventWidgetCatchkey(tux_right_keyfire_val);
+catchKey_event(tux_right_keyfire_val);
-eventWidgetCatchkey(tux_left_keyup_val);
+catchKey_event(tux_left_keyup_val);
-eventWidgetCatchkey(tux_left_keydown_val);
+catchKey_event(tux_left_keydown_val);
-eventWidgetCatchkey(tux_left_keyleft_val);
+catchKey_event(tux_left_keyleft_val);
-eventWidgetCatchkey(tux_left_keyright_val);
+catchKey_event(tux_left_keyright_val);
-eventWidgetCatchkey(tux_left_keyswitch_val);
+catchKey_event(tux_left_keyswitch_val);
-eventWidgetCatchkey(tux_left_keyfire_val);
+catchKey_event(tux_left_keyfire_val);
}
void
stopScreenSettingKeys()
{
- unregisterHotKey(SDLK_ESCAPE);
+ unhotKey_register(SDLK_ESCAPE);
}
void
- initScreenSettingKeys()
+ settingKey_int()
{
image_t * image;
-initKeyTable();
+keyTable_init();
-image = getImage(IMAGE_GROUP_BASE, "screen_main");
+image = image_get(IMAGE_GROUP_BASE, "screen_main");
-image_backgorund = newWidgetImage(0, 0, image);
+image_backgorund = wid_image_new(0, 0, image);
button_back =
- newWidgetButton(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
+ button_new(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100,
eventWidget);
tux_left =
- newWidgetLabel(_("Player 2"), WINDOW_SIZE_X / 4, 150,
+ label_new(_("Player 2"), WINDOW_SIZE_X / 4, 150,
WIDGET_LABEL_CENTER);
tux_left_keyup =
- newWidgetLabel(_("Up"), 50, tux_left->y + 50, WIDGET_LABEL_LEFT);
+ label_new(_("Up"), 50, tux_left->y + 50, WIDGET_LABEL_LEFT);
tux_left_keydown =
- newWidgetLabel(_("Down:"), tux_left_keyup->x, tux_left_keyup->y + 20,
+ label_new(_("Down:"), tux_left_keyup->x, tux_left_keyup->y + 20,
WIDGET_LABEL_LEFT);
tux_left_keyleft =
- newWidgetLabel(_("Left:"), tux_left_keyup->x,
+ label_new(_("Left:"), tux_left_keyup->x,
tux_left_keydown->y + 20, WIDGET_LABEL_LEFT);
tux_left_keyright =
- newWidgetLabel(_("Right:"), tux_left_keyup->x,
+ label_new(_("Right:"), tux_left_keyup->x,
tux_left_keyleft->y + 20, WIDGET_LABEL_LEFT);
tux_left_keyfire =
- newWidgetLabel(_("Fire gun:"), tux_left_keyup->x,
+ label_new(_("Fire gun:"), tux_left_keyup->x,
tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
tux_left_keyswitch =
- newWidgetLabel(_("Switch gun:"), tux_left_keyup->x,
+ label_new(_("Switch gun:"), tux_left_keyup->x,
tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
tux_right =
- newWidgetLabel(_("Player 1"), WINDOW_SIZE_X / 2 + WINDOW_SIZE_X / 4,
+ label_new(_("Player 1"), WINDOW_SIZE_X / 2 + WINDOW_SIZE_X / 4,
tux_left->y, WIDGET_LABEL_CENTER);
tux_right_keyup =
- newWidgetLabel(_("Up:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
+ label_new(_("Up:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
tux_left->y + 50, WIDGET_LABEL_LEFT);
tux_right_keydown =
- newWidgetLabel(_("Down:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
+ label_new(_("Down:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
tux_right_keyleft =
- newWidgetLabel(_("Left:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
+ label_new(_("Left:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
tux_right_keydown->y + 20, WIDGET_LABEL_LEFT);
tux_right_keyright =
- newWidgetLabel(_("Right:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
+ label_new(_("Right:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
tux_right_keyleft->y + 20, WIDGET_LABEL_LEFT);
tux_right_keyfire =
- newWidgetLabel(_("Fire gun:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
+ label_new(_("Fire gun:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x,
tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
tux_right_keyswitch =
- newWidgetLabel(_("Switch gun:"),
+ label_new(_("Switch gun:"),
WINDOW_SIZE_X / 2 + tux_left_keyup->x,
tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
tux_left_keyup_val =
- newWidgetCatchkey(keytable[6], tux_left_keyup->x + 200,
+ catchKey_new(keytable[6], tux_left_keyup->x + 200,
tux_left->y + 50, eventWidget);
tux_left_keydown_val =
- newWidgetCatchkey(keytable[9], tux_left_keyup_val->x,
+ catchKey_new(keytable[9], tux_left_keyup_val->x,
tux_left_keyup->y + 20, eventWidget);
tux_left_keyleft_val =
- newWidgetCatchkey(keytable[8], tux_left_keyup_val->x,
+ catchKey_new(keytable[8], tux_left_keyup_val->x,
tux_left_keydown->y + 20, eventWidget);
tux_left_keyright_val =
- newWidgetCatchkey(keytable[7], tux_left_keyup_val->x,
+ catchKey_new(keytable[7], tux_left_keyup_val->x,
tux_left_keyleft->y + 20, eventWidget);
tux_left_keyfire_val =
- newWidgetCatchkey(keytable[10], tux_left_keyup_val->x,
+ catchKey_new(keytable[10], tux_left_keyup_val->x,
tux_left_keyright->y + 20, eventWidget);
tux_left_keyswitch_val =
- newWidgetCatchkey(keytable[11], tux_left_keyup_val->x,
+ catchKey_new(keytable[11], tux_left_keyup_val->x,
tux_left_keyfire->y + 20, eventWidget);
tux_right_keyup_val =
- newWidgetCatchkey(keytable[0],
+ catchKey_new(keytable[0],
WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
tux_left->y + 50, eventWidget);
tux_right_keydown_val =
- newWidgetCatchkey(keytable[3],
+ catchKey_new(keytable[3],
WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
tux_left_keyup->y + 20, eventWidget);
tux_right_keyleft_val =
- newWidgetCatchkey(keytable[2],
+ catchKey_new(keytable[2],
WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
tux_right_keydown->y + 20, eventWidget);
tux_right_keyright_val =
- newWidgetCatchkey(keytable[1],
+ catchKey_new(keytable[1],
WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
tux_right_keyleft->y + 20, eventWidget);
tux_right_keyfire_val =
- newWidgetCatchkey(keytable[4],
+ catchKey_new(keytable[4],
WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
tux_left_keyright->y + 20, eventWidget);
tux_right_keyswitch_val =
- newWidgetCatchkey(keytable[5],
+ catchKey_new(keytable[5],
WINDOW_SIZE_X / 2 + tux_left_keyup_val->x,
tux_left_keyfire->y + 20, eventWidget);
-registerScreen(newScreen
- ("settingKeys", startScreenSettingKeys,
- eventScreenSettingKeys,
-drawScreenSettingKeys,
+screen_register(screen_new
+ ("settingKeys", screen_startSettingKeys,
+ settingKey_event,
+settingKey_draw,
stopScreenSettingKeys));
}
-void quitKeyTable()
+void keyTable_quit()
{
- destroyTextFile(keycontrolFile);
+ textFile_destroy(keycontrolFile);
}
void saveKeyTable(textFile_t * configFile)
{
char str[STR_SIZE];
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyup_val));
+ sprintf(str, "%d", catchKey_get(tux_left_keyup_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_UP", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keydown_val));
+ sprintf(str, "%d", catchKey_get(tux_left_keydown_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_DOWN", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyleft_val));
+ sprintf(str, "%d", catchKey_get(tux_left_keyleft_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_LEFT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyright_val));
+ sprintf(str, "%d", catchKey_get(tux_left_keyright_val));
setValueInConfigFile(configFile, "TUX_LEFT_MOVE_RIGHT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyfire_val));
+ sprintf(str, "%d", catchKey_get(tux_left_keyfire_val));
setValueInConfigFile(configFile, "TUX_LEFT_SHOOT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_left_keyswitch_val));
+ sprintf(str, "%d", catchKey_get(tux_left_keyswitch_val));
setValueInConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyup_val));
+ sprintf(str, "%d", catchKey_get(tux_right_keyup_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_UP", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keydown_val));
+ sprintf(str, "%d", catchKey_get(tux_right_keydown_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_DOWN", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyleft_val));
+ sprintf(str, "%d", catchKey_get(tux_right_keyleft_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_LEFT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyright_val));
+ sprintf(str, "%d", catchKey_get(tux_right_keyright_val));
setValueInConfigFile(configFile, "TUX_RIGHT_MOVE_RIGHT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyfire_val));
+ sprintf(str, "%d", catchKey_get(tux_right_keyfire_val));
setValueInConfigFile(configFile, "TUX_RIGHT_SHOOT", str);
- sprintf(str, "%d", getWidgetCatchKey(tux_right_keyswitch_val));
+ sprintf(str, "%d", catchKey_get(tux_right_keyswitch_val));
setValueInConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", str);
- saveTextFile(configFile);
+ textFile_save(configFile);
}
-void quitScreenSettingKeys()
+void settingKey_quit()
{
saveKeyTable(keycontrolFile);
- quitKeyTable();
+ keyTable_quit();
// key names
- destroyWidgetImage(image_backgorund);
+ wid_image_destroy(image_backgorund);
- destroyWidgetLabel(tux_right);
- destroyWidgetLabel(tux_left);
- destroyWidgetLabel(tux_right_keyup);
- destroyWidgetLabel(tux_right_keydown);
- destroyWidgetLabel(tux_right_keyleft);
- destroyWidgetLabel(tux_right_keyright);
- destroyWidgetLabel(tux_right_keyswitch);
- destroyWidgetLabel(tux_right_keyfire);
- destroyWidgetLabel(tux_left_keyup);
- destroyWidgetLabel(tux_left_keydown);
- destroyWidgetLabel(tux_left_keyright);
- destroyWidgetLabel(tux_left_keyleft);
- destroyWidgetLabel(tux_left_keyswitch);
- destroyWidgetLabel(tux_left_keyfire);
+ label_destroy(tux_right);
+ label_destroy(tux_left);
+ label_destroy(tux_right_keyup);
+ label_destroy(tux_right_keydown);
+ label_destroy(tux_right_keyleft);
+ label_destroy(tux_right_keyright);
+ label_destroy(tux_right_keyswitch);
+ label_destroy(tux_right_keyfire);
+ label_destroy(tux_left_keyup);
+ label_destroy(tux_left_keydown);
+ label_destroy(tux_left_keyright);
+ label_destroy(tux_left_keyleft);
+ label_destroy(tux_left_keyswitch);
+ label_destroy(tux_left_keyfire);
// key values
- destroyWidgetCatchkey(tux_right_keyup_val);
+ catchKey_destroy(tux_right_keyup_val);
- destroyWidgetCatchkey(tux_right_keydown_val);
- destroyWidgetCatchkey(tux_right_keyleft_val);
- destroyWidgetCatchkey(tux_right_keyright_val);
- destroyWidgetCatchkey(tux_right_keyswitch_val);
- destroyWidgetCatchkey(tux_right_keyfire_val);
- destroyWidgetCatchkey(tux_left_keyup_val);
- destroyWidgetCatchkey(tux_left_keydown_val);
- destroyWidgetCatchkey(tux_left_keyleft_val);
- destroyWidgetCatchkey(tux_left_keyright_val);
- destroyWidgetCatchkey(tux_left_keyswitch_val);
- destroyWidgetCatchkey(tux_left_keyfire_val);
- destroyWidgetButton(button_back);
+ catchKey_destroy(tux_right_keydown_val);
+ catchKey_destroy(tux_right_keyleft_val);
+ catchKey_destroy(tux_right_keyright_val);
+ catchKey_destroy(tux_right_keyswitch_val);
+ catchKey_destroy(tux_right_keyfire_val);
+ catchKey_destroy(tux_left_keyup_val);
+ catchKey_destroy(tux_left_keydown_val);
+ catchKey_destroy(tux_left_keyleft_val);
+ catchKey_destroy(tux_left_keyright_val);
+ catchKey_destroy(tux_left_keyswitch_val);
+ catchKey_destroy(tux_left_keyfire_val);
+ button_destroy(button_back);
}
diff --git a/src/screen/settingKeys.h b/src/screen/settingKeys.h index c90006e..a52a4a8 100644 --- a/src/screen/settingKeys.h +++ b/src/screen/settingKeys.h @@ -16,12 +16,12 @@ # define KEY_LENGTH 12
# include "main.h"
-
extern void initScreenSettingKeys(); -
extern void drawScreenSettingKeys(); -
extern void eventScreenSettingKeys(); -
extern void quitScreenSettingKeys(); -
extern void initKeyTable(); -
extern int getKey(int n); -
extern void quitKeyTable(); +
extern void settingKey_int(); +
extern void settingKey_draw(); +
extern void settingKey_event(); +
extern void settingKey_quit(); +
extern void keyTable_init(); +
extern int keyTable_get_key(int n); +
extern void keyTable_quit(); #endif /*
*/ diff --git a/src/screen/table.c b/src/screen/table.c index 5abb3c9..7d5771f 100644 --- a/src/screen/table.c +++ b/src/screen/table.c @@ -34,53 +34,53 @@ static textFile_t *textFile; static void hotkey_escape() { - setScreen("mainMenu"); + screen_set("mainMenu"); } -void startScreenTable() +void table_start() { #ifndef NO_SOUND - playMusic("menu", MUSIC_GROUP_BASE); + music_play("menu", MUSIC_GROUP_BASE); #endif - registerHotKey(SDLK_ESCAPE, hotkey_escape); + hotKey_register(SDLK_ESCAPE, hotkey_escape); } -void drawScreenTable() +void table_draw() { int i; - drawWidgetImage(image_backgorund); + wid_image_draw(image_backgorund); - drawWidgetButton(button_back); + button_draw(button_back); for (i = 0; i < listWidgetLabelNumer->count; i++) { widget_t *this; this = (widget_t *) listWidgetLabelNumer->list[i]; - drawWidgetLabel(this); + label_draw(this); } for (i = 0; i < listWidgetLabelName->count; i++) { widget_t *this; this = (widget_t *) listWidgetLabelName->list[i]; - drawWidgetLabel(this); + label_draw(this); } for (i = 0; i < listWidgetLabelScore->count; i++) { widget_t *this; this = (widget_t *) listWidgetLabelScore->list[i]; - drawWidgetLabel(this); + label_draw(this); } } -void eventScreenTable() +void table_event() { - eventWidgetButton(button_back); + button_event(button_back); } -void stopScreenTable() +void table_stop() { - unregisterHotKey(SDLK_ESCAPE); + unhotKey_register(SDLK_ESCAPE); } static void eventWidget(void *p) @@ -90,7 +90,7 @@ static void eventWidget(void *p) button = (widget_t *) (p); if (button == button_back) { - setScreen("mainMenu"); + screen_set("mainMenu"); } } @@ -107,14 +107,14 @@ static void setWidgetLabel() if (listWidgetLabelNumer != NULL || listWidgetLabelName != NULL || listWidgetLabelScore != NULL) { - destroyListItem(listWidgetLabelNumer, destroyWidgetLabel); - destroyListItem(listWidgetLabelName, destroyWidgetLabel); - destroyListItem(listWidgetLabelScore, destroyWidgetLabel); + list_destroy_item(listWidgetLabelNumer, label_destroy); + list_destroy_item(listWidgetLabelName, label_destroy); + list_destroy_item(listWidgetLabelScore, label_destroy); } - listWidgetLabelNumer = newList(); - listWidgetLabelName = newList(); - listWidgetLabelScore = newList(); + listWidgetLabelNumer = list_new(); + listWidgetLabelName = list_new(); + listWidgetLabelScore = list_new(); for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) { widget_t *label; @@ -128,14 +128,14 @@ static void setWidgetLabel() sscanf(line, "%s %s", name, score); sprintf(num, "%2d)", i + 1); - label = newWidgetLabel(num, WINDOW_SIZE_X / 2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT); - addList(listWidgetLabelNumer, label); + label = label_new(num, WINDOW_SIZE_X / 2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT); + list_add(listWidgetLabelNumer, label); - label = newWidgetLabel(name, WINDOW_SIZE_X / 2, 200 + i * 20, WIDGET_LABEL_CENTER); - addList(listWidgetLabelName, label); + label = label_new(name, WINDOW_SIZE_X / 2, 200 + i * 20, WIDGET_LABEL_CENTER); + list_add(listWidgetLabelName, label); - label = newWidgetLabel(score, WINDOW_SIZE_X / 2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT); - addList(listWidgetLabelScore, label); + label = label_new(score, WINDOW_SIZE_X / 2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT); + list_add(listWidgetLabelScore, label); } } @@ -144,13 +144,13 @@ static void loadHighscoreFile() char path[STR_PATH_SIZE]; int i; - sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME, getHomeDirector()); - textFile = loadTextFile(path); + sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME, homeDirector_get()); + textFile = textFile_load(path); if (textFile == NULL) { fprintf(stderr, _("I am unable to load: \"%s\"!\n"), path); fprintf(stderr, _("Creating: \"%s\"\n"), path); - textFile = newTextFile(path); + textFile = textFile_new(path); } else { return; } @@ -161,13 +161,13 @@ static void loadHighscoreFile() } for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) { - addList(textFile->text, strdup("no_name 0")); + list_add(textFile->text, strdup("no_name 0")); } - saveTextFile(textFile); + textFile_save(textFile); } -int addPlayerInHighScore(char *name, int score) +int table_add(char *name, int score) { int i; @@ -183,8 +183,8 @@ int addPlayerInHighScore(char *name, int score) char new[STR_SIZE]; sprintf(new, "%s %d", name, score); - insList(textFile->text, i, strdup(new)); - delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free); + list_ins(textFile->text, i, strdup(new)); + list_del_item(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free); setWidgetLabel(); return 0; @@ -194,14 +194,14 @@ int addPlayerInHighScore(char *name, int score) return -1; } -void initScreenTable() +void table_init() { image_t *image; - image = addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE); - image_backgorund = newWidgetImage(0, 0, image); + image = image_add("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE); + image_backgorund = wid_image_new(0, 0, image); - button_back = newWidgetButton(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + button_back = button_new(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, WINDOW_SIZE_Y - 100, eventWidget); loadHighscoreFile(); @@ -210,20 +210,20 @@ void initScreenTable() listWidgetLabelScore = NULL; setWidgetLabel(); - registerScreen(newScreen("table", startScreenTable, eventScreenTable, drawScreenTable, stopScreenTable)); + screen_register(screen_new("table", table_start, table_event, table_draw, table_stop)); } -void quitScreenTable() +void table_quit() { - destroyWidgetImage(image_backgorund); + wid_image_destroy(image_backgorund); - destroyWidgetButton(button_back); - destroyListItem(listWidgetLabelNumer, destroyWidgetLabel); - destroyListItem(listWidgetLabelName, destroyWidgetLabel); - destroyListItem(listWidgetLabelScore, destroyWidgetLabel); + button_destroy(button_back); + list_destroy_item(listWidgetLabelNumer, label_destroy); + list_destroy_item(listWidgetLabelName, label_destroy); + list_destroy_item(listWidgetLabelScore, label_destroy); if (textFile != NULL) { - saveTextFile(textFile); - destroyTextFile(textFile); + textFile_save(textFile); + textFile_destroy(textFile); } } diff --git a/src/screen/table.h b/src/screen/table.h index a91b233..9f4bf46 100644 --- a/src/screen/table.h +++ b/src/screen/table.h @@ -6,12 +6,12 @@ # 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(); +extern void table_start(); +extern void table_draw(); +extern void table_event(); +extern void table_stop(); +extern int table_add(char *name, int score); +extern void table_init(); +extern void table_quit(); #endif diff --git a/src/screen/world.c b/src/screen/world.c index 5fa3ecd..cb0daf6 100644 --- a/src/screen/world.c +++ b/src/screen/world.c @@ -53,7 +53,7 @@ static bool_t isEndWorld; static tux_t *tuxWithControlRightKeyboard; static tux_t *tuxWithControlLeftKeyboard; -bool_t isScreenWorldInicialized() +bool_t word_is_inicialized() { return isScreenWorldInit; } @@ -62,38 +62,38 @@ void setGameType() { int ret = 0; - ret = initNetMuliplayer(getSettingGameType(), getSettingIP(), - getSettingPort(), getSettingProto()); + ret = netMultiplayer_init(publicServer_get_settingGameType(), publicServer_get_settingIP(), + publicServer_get_settingPort(), publicServer_get_settingProto()); if (ret != 0) { fprintf(stderr, _("Network initialization error!\n")); - setWorldEnd(); + word_do_end(); } } -void setWorldArena(arenaFile_t * arenaFile) +void word_set_arena(arenaFile_t * arenaFile) { - arena = getArena(arenaFile); + arena = arenaFile_get_arena(arenaFile); #ifndef NO_SOUND - playMusic(arena->music, MUSIC_GROUP_USER); + music_play(arena->music, MUSIC_GROUP_USER); #endif } -void setWorldEnd() +void word_do_end() { isEndWorld = TRUE; } static void timer_endArena() { - if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) { - setWorldEnd(); + if (netMultiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { + word_do_end(); return; } } -void countRoundInc() +void word_inc_round() { if (arena->max_countRound == WORLD_COUNT_ROUND_UNLIMITED || arena->countRound >= arena->max_countRound) { @@ -106,9 +106,9 @@ void countRoundInc() if (arena->countRound >= arena->max_countRound) { //printf("count %d ending\n", count); #ifndef NO_SOUND - playSound("end", SOUND_GROUP_BASE); + sound_play("end", SOUND_GROUP_BASE); #endif - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_endArena, NULL, TIMER_END_ARENA); + timer_add_task(arena_get_current()->listTimer, TIMER_ONE, timer_endArena, NULL, TIMER_END_ARENA); } } @@ -117,58 +117,58 @@ void prepareArena() tux_t *tux; char name[STR_NAME_SIZE]; - //printf("getSettingAI = %s\n", getSettingAI()); - setCurrentArena(NULL); + //printf("publicServer_get_settingAI = %s\n", publicServer_get_settingAI()); + arena_set_current(NULL); tuxWithControlRightKeyboard = NULL; tuxWithControlLeftKeyboard = NULL; - if (getGemeTypeLoadSession() != NULL) { - loadArena(getGemeTypeLoadSession()); + if (gameType_load_session() != NULL) { + load_arena(gameType_load_session()); return; } - switch (getNetTypeGame()) { + switch (netMultiplayer_get_game_type()) { case NET_GAME_TYPE_NONE: - setWorldArena(getChoiceArena()); - addNewItem(arena->spaceItem, ID_UNKNOWN); - getSettingCountRound(&arena->max_countRound); + word_set_arena(choiceArena_get()); + item_add_new_item(arena->spaceItem, ID_UNKNOWN); + publicServer_get_settingCountRound(&arena->max_countRound); - tux = newTux(); + tux = tux_new(); tux->control = TUX_CONTROL_KEYBOARD_RIGHT; tuxWithControlRightKeyboard = tux; - getSettingNameRight(name); - tuxSetName(tux, name); - addObjectToSpace(arena->spaceTux, tux); + publicServer_get_settingNameRight(name); + tux_set_name(tux, name); + space_add(arena->spaceTux, tux); - tux = newTux(); + tux = tux_new(); tux->control = TUX_CONTROL_KEYBOARD_LEFT; tuxWithControlLeftKeyboard = tux; - getSettingNameLeft(name); - tuxSetName(tux, name); - addObjectToSpace(arena->spaceTux, tux); + publicServer_get_settingNameLeft(name); + tux_set_name(tux, name); + space_add(arena->spaceTux, tux); - if (isSettingAI()) { + if (setting_is_ai()) { tux->control = TUX_CONTROL_AI; - if (loadModule("libmodAI") != 0) { + if (module_load("libmodAI") != 0) { tux->control = TUX_CONTROL_KEYBOARD_LEFT; } } - //printf("getGemeTypeLoadSession = %s\n", getGemeTypeLoadSession()); + //printf("gameType_load_session = %s\n", gameType_load_session()); break; case NET_GAME_TYPE_SERVER: - setWorldArena(getChoiceArena()); - addNewItem(arena->spaceItem, ID_UNKNOWN); - getSettingCountRound(&arena->max_countRound); + word_set_arena(choiceArena_get()); + item_add_new_item(arena->spaceItem, ID_UNKNOWN); + publicServer_get_settingCountRound(&arena->max_countRound); - tux = newTux(); + tux = tux_new(); tux->control = TUX_CONTROL_KEYBOARD_RIGHT; tuxWithControlRightKeyboard = tux; - getSettingNameRight(name); - tuxSetName(tux, name); - addObjectToSpace(arena->spaceTux, tux); + publicServer_get_settingNameRight(name); + tux_set_name(tux, name); + space_add(arena->spaceTux, tux); break; case NET_GAME_TYPE_CLIENT: @@ -176,30 +176,30 @@ void prepareArena() } } -void drawWorld() +void word_draw() { if (arena != NULL) { - drawArena(arena); - drawPanel(tuxWithControlRightKeyboard, tuxWithControlLeftKeyboard); + arena_draw(arena); + panel_draw(tuxWithControlRightKeyboard, tuxWithControlLeftKeyboard); if (arena->w > WINDOW_SIZE_X || arena->h > WINDOW_SIZE_Y) { - drawRadar(arena); + radar_draw(arena); } } - drawChat(); - drawPauza(); - drawTerm(); - drawSaveDialog(); + chat_draw(); + pauza_draw(); + term_draw(); + saveDialog_draw(); } static void netAction(tux_t * tux, int action) { - if (getSettingGameType() == NET_GAME_TYPE_SERVER) { + if (publicServer_get_settingGameType() == NET_GAME_TYPE_SERVER) { proto_send_event_server(PROTO_SEND_ALL_SEES_TUX, NULL, tux, action); } - if (getSettingGameType() == NET_GAME_TYPE_CLIENT) { + if (publicServer_get_settingGameType() == NET_GAME_TYPE_CLIENT) { proto_send_event_client(action); } } @@ -216,80 +216,80 @@ static void control_keyboard_right(tux_t * tux) countKey = 0; - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED && tux->isCanSwitchGun == TRUE) { netAction(tux, TUX_SWITCH_GUN); - actionTux(tux, TUX_SWITCH_GUN); + tux_action(tux, TUX_SWITCH_GUN); return; } - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE) { netAction(tux, TUX_SHOT); - actionTux(tux, TUX_SHOT); + tux_action(tux, TUX_SHOT); return; } - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_UP)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_RIGHT_MOVE_UP)) goto tuUp; if (countKey == 1) - lastKey = getKey(KEY_TUX_RIGHT_MOVE_UP); + lastKey = keyTable_get_key(KEY_TUX_RIGHT_MOVE_UP); netAction(tux, TUX_UP); - actionTux(tux, TUX_UP); + tux_action(tux, TUX_UP); return; tuUp:; } - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_RIGHT)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)) goto tuRight; if (countKey == 1) - lastKey = getKey(KEY_TUX_RIGHT_MOVE_RIGHT); + lastKey = keyTable_get_key(KEY_TUX_RIGHT_MOVE_RIGHT); netAction(tux, TUX_RIGHT); - actionTux(tux, TUX_RIGHT); + tux_action(tux, TUX_RIGHT); return; tuRight:; } - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_LEFT)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_RIGHT_MOVE_LEFT)) goto tuLeft; if (countKey == 1) - lastKey = getKey(KEY_TUX_RIGHT_MOVE_LEFT); + lastKey = keyTable_get_key(KEY_TUX_RIGHT_MOVE_LEFT); netAction(tux, TUX_LEFT); - actionTux(tux, TUX_LEFT); + tux_action(tux, TUX_LEFT); return; tuLeft:; } - if (mapa[(SDLKey) getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_DOWN)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_RIGHT_MOVE_DOWN)) goto tuDown; if (countKey == 1) - lastKey = getKey(KEY_TUX_RIGHT_MOVE_DOWN); + lastKey = keyTable_get_key(KEY_TUX_RIGHT_MOVE_DOWN); netAction(tux, TUX_DOWN); - actionTux(tux, TUX_DOWN); + tux_action(tux, TUX_DOWN); return; tuDown:; @@ -308,75 +308,75 @@ static void control_keyboard_left(tux_t * tux) countKey = 0; - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) countKey++; - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED) { + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED) { if (tux->isCanSwitchGun == TRUE) { - actionTux(tux, TUX_SWITCH_GUN); + tux_action(tux, TUX_SWITCH_GUN); return; } } - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE) { - actionTux(tux, TUX_SHOT); + tux_action(tux, TUX_SHOT); return; } - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_UP)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_LEFT_MOVE_UP)) goto tuUp; if (countKey == 1) - lastKey = getKey(KEY_TUX_LEFT_MOVE_UP); - actionTux(tux, TUX_UP); + lastKey = keyTable_get_key(KEY_TUX_LEFT_MOVE_UP); + tux_action(tux, TUX_UP); return; tuUp:; } - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_RIGHT)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_LEFT_MOVE_RIGHT)) goto tuRight; if (countKey == 1) - lastKey = getKey(KEY_TUX_LEFT_MOVE_RIGHT); - actionTux(tux, TUX_RIGHT); + lastKey = keyTable_get_key(KEY_TUX_LEFT_MOVE_RIGHT); + tux_action(tux, TUX_RIGHT); return; tuRight:; } - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_LEFT)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_LEFT_MOVE_LEFT)) goto tuLeft; if (countKey == 1) - lastKey = getKey(KEY_TUX_LEFT_MOVE_LEFT); - actionTux(tux, TUX_LEFT); + lastKey = keyTable_get_key(KEY_TUX_LEFT_MOVE_LEFT); + tux_action(tux, TUX_LEFT); return; tuLeft:; } - if (mapa[(SDLKey) getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_DOWN)) + if (mapa[(SDLKey) keyTable_get_key(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) { + if (countKey > 1 && lastKey == keyTable_get_key(KEY_TUX_LEFT_MOVE_DOWN)) goto tuDown; if (countKey == 1) - lastKey = getKey(KEY_TUX_LEFT_MOVE_DOWN); - actionTux(tux, TUX_DOWN); + lastKey = keyTable_get_key(KEY_TUX_LEFT_MOVE_DOWN); + tux_action(tux, TUX_DOWN); return; tuDown:; @@ -386,12 +386,12 @@ static void control_keyboard_left(tux_t * tux) static void eventEnd() { if (isEndWorld == TRUE) { - setScreen("analyze"); + screen_set("analyze"); return; } } -tux_t *getControlTux(int control_type) +tux_t *word_get_control_tux(int control_type) { switch (control_type) { case TUX_CONTROL_KEYBOARD_RIGHT: @@ -405,7 +405,7 @@ tux_t *getControlTux(int control_type) return NULL; } -void setControlTux(tux_t * tux, int control_type) +void word_set_control_tux(tux_t * tux, int control_type) { switch (control_type) { case TUX_CONTROL_KEYBOARD_RIGHT: @@ -417,7 +417,7 @@ void setControlTux(tux_t * tux, int control_type) } } -void tuxControl(tux_t * p) +void word_tux_control(tux_t * p) { assert(p != NULL); @@ -431,57 +431,57 @@ void tuxControl(tux_t * p) break; case TUX_CONTROL_KEYBOARD_LEFT: - if (isChatActive() == FALSE) { + if (chat_is_active() == FALSE) { control_keyboard_left(p); } break; case TUX_CONTROL_KEYBOARD_RIGHT: - if (isChatActive() == FALSE) { + if (chat_is_active() == FALSE) { control_keyboard_right(p); } break; } } -void eventWorld() +void word_event() { tux_t *thisTux; if (arena == NULL) { - eventNetMultiplayer(); + netMultiplayer_event(); eventEnd(); return; } - eventNetMultiplayer(); + netMultiplayer_event(); - if (isPauzeActive() == FALSE && isSaveDialogActive() == FALSE) { - eventArena(arena); - //eventModule(); + if (pauza_is_active() == FALSE && saveDialog_is_active() == FALSE) { + arena_event(arena); + //module_event(); } - thisTux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT); + thisTux = word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT); - addToRadar(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_YOU); + radar_add(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_YOU); - thisTux = getControlTux(TUX_CONTROL_KEYBOARD_LEFT); + thisTux = word_get_control_tux(TUX_CONTROL_KEYBOARD_LEFT); if (thisTux != NULL) { - addToRadar(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_TUX); + radar_add(thisTux->id, thisTux->x, thisTux->y, RADAR_TYPE_TUX); } eventEnd(); - eventChat(); - eventPauza(); - eventTerm(); - eventSaveDialog(); + chat_event(); + pauza_event(); + term_event(); + saveDialog_event(); } static void hotkey_escape() { - setWorldEnd(); + word_do_end(); } void startWorld() @@ -489,32 +489,32 @@ void startWorld() arena = NULL; isEndWorld = FALSE; - registerHotKey(SDLK_ESCAPE, hotkey_escape); - initArena(); - initListID(); - initRadar(); - initPauza(); - initTerm(); - initSaveDialog(); + hotKey_register(SDLK_ESCAPE, hotkey_escape); + arena_init(); + id_init_list(); + radar_init(); + pauza_init(); + term_init(); + saveDialog_init(); - initModule(); + module_init(); setGameType(); - initChat(); + chat_init(); prepareArena(); } static void action_analyze(space_t * space, tux_t * tux, void *p) { - addAnalyze(tux->name, tux->score); + analyze_add(tux->name, tux->score); } static void setAnalyze() { - restartAnalyze(); + analyze_restart(); - actionSpace(arena->spaceTux, action_analyze, NULL); + space_action(arena->spaceTux, action_analyze, NULL); - endAnalyze(); + analyze_end(); } static void setTable() @@ -522,19 +522,19 @@ static void setTable() tux_t *tuxRight; tux_t *tuxLeft; - if (getSettingGameType() != NET_GAME_TYPE_NONE) { + if (publicServer_get_settingGameType() != NET_GAME_TYPE_NONE) { return; } - tuxRight = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT); - tuxLeft = getControlTux(TUX_CONTROL_KEYBOARD_LEFT); + tuxRight = word_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT); + tuxLeft = word_get_control_tux(TUX_CONTROL_KEYBOARD_LEFT); if (tuxRight->score > tuxLeft->score) { - addPlayerInHighScore(tuxRight->name, tuxRight->score); + table_add(tuxRight->name, tuxRight->score); } if (tuxLeft->score > tuxRight->score) { - addPlayerInHighScore(tuxLeft->name, tuxLeft->score); + table_add(tuxLeft->name, tuxLeft->score); } } @@ -545,64 +545,64 @@ void stoptWorld() setAnalyze(); } - unregisterHotKey(SDLK_ESCAPE); - quitArena(); + unhotKey_register(SDLK_ESCAPE); + arena_quit(); - quitNetMultiplayer(); + netMultiplayer_quit(); if (arena != NULL) { - destroyArena(arena); + arena_destroy(arena); } - quitRadar(); - quitPauza(); - quitTerm(); - quitSaveDialog(); + radar_quit(); + pauza_quit(); + term_quit(); + saveDialog_quit(); #ifndef NO_SOUND - stopMusic(); + music_stop(); #endif - delAllImageInGroup(IMAGE_GROUP_USER); + image_del_all_image_in_group(IMAGE_GROUP_USER); #ifndef NO_SOUND - delAllMusicInGroup(MUSIC_GROUP_USER); + music_del_all_in_group(MUSIC_GROUP_USER); #endif - quitModule(); - quitChat(); - quitListID(); + module_quit(); + chat_quit(); + id_quit_list(); } -void initWorld() +void word_init() { - assert(isImageInicialized() == TRUE); - assert(isTuxInicialized() == TRUE); - assert(isShotInicialized() == TRUE); - assert(isPanelInicialized() == TRUE); - assert(isScreenInicialized() == TRUE); + assert(image_is_inicialized() == TRUE); + assert(tux_is_inicialized() == TRUE); + assert(shot_is_inicialized() == TRUE); + assert(panel_is_inicialized() == TRUE); + assert(screen_is_inicialized() == TRUE); - registerScreen(newScreen - ("world", startWorld, eventWorld, drawWorld, stoptWorld)); + screen_register(screen_new + ("world", startWorld, word_event, word_draw, 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); - addSound("gun_revolver.ogg", "gun_revolver", SOUND_GROUP_BASE); - addSound("gun_scatter.ogg", "gun_scatter", SOUND_GROUP_BASE); - addSound("gun_tommy.ogg", "gun_tommy", SOUND_GROUP_BASE); - addSound("put_mine.ogg", "put_mine", SOUND_GROUP_BASE); - addSound("teleport.ogg", "teleport", SOUND_GROUP_BASE); - addSound("item_bonus.ogg", "item_bonus", SOUND_GROUP_BASE); - 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); + sound_add("dead.ogg", "dead", SOUND_GROUP_BASE); + sound_add("explozion.ogg", "explozion", SOUND_GROUP_BASE); + sound_add("gun_lasser.ogg", "gun_lasser", SOUND_GROUP_BASE); + sound_add("gun_revolver.ogg", "gun_revolver", SOUND_GROUP_BASE); + sound_add("gun_scatter.ogg", "gun_scatter", SOUND_GROUP_BASE); + sound_add("gun_tommy.ogg", "gun_tommy", SOUND_GROUP_BASE); + sound_add("put_mine.ogg", "put_mine", SOUND_GROUP_BASE); + sound_add("teleport.ogg", "teleport", SOUND_GROUP_BASE); + sound_add("item_bonus.ogg", "item_bonus", SOUND_GROUP_BASE); + sound_add("item_gun.ogg", "item_gun", SOUND_GROUP_BASE); + sound_add("switch_gun.ogg", "switch_gun", SOUND_GROUP_BASE); + sound_add("end.ogg", "end", SOUND_GROUP_BASE); #endif isScreenWorldInit = TRUE; } -void quitWorld() +void word_quit() { DEBUG_MSG(_("Quitting screen world\n")); isScreenWorldInit = FALSE; diff --git a/src/screen/world.h b/src/screen/world.h index 67935f7..0df8a48 100644 --- a/src/screen/world.h +++ b/src/screen/world.h @@ -13,18 +13,18 @@ # define WORLD_COUNT_ROUND_UNLIMITED -1 # define LAG_SERVER_UNKNOWN -1 -extern bool_t isScreenWorldInicialized(); -extern void initWorld(); -extern void setWorldArena(arenaFile_t * arenaFile); -extern void setWorldEnd(); -extern void countRoundInc(); -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(); +extern bool_t word_is_inicialized(); +extern void word_init(); +extern void word_set_arena(arenaFile_t * arenaFile); +extern void word_do_end(); +extern void word_inc_round(); +extern tux_t *word_get_control_tux(int control_type); +extern void word_set_control_tux(tux_t * tux, int control_type); +extern void word_tux_control(tux_t * p); +extern void word_draw(); +extern void word_event(); +extern void word_start(); +extern void word_stop(); +extern void word_quit(); #endif diff --git a/src/server/highScore.c b/src/server/highScore.c index 89476ff..affd28f 100644 --- a/src/server/highScore.c +++ b/src/server/highScore.c @@ -11,16 +11,16 @@ static textFile_t *textFile; -void initHighScore(char *file) +void highScore_init(char *file) { int i; - textFile = loadTextFile(file); + textFile = textFile_load(file); if (textFile == NULL) { fprintf(stderr, _("I am unable to load: \"%s\"!\n"), file); fprintf(stderr, _("Creating: \"%s\"\n"), file); - textFile = newTextFile(file); + textFile = textFile_new(file); } else { DEBUG_MSG(_("Scorefile: \"%s\"\n"), file); @@ -33,13 +33,13 @@ void initHighScore(char *file) } for (i = 0; i < HIGHSCORE_MAX_PLAYERS; i++) { - addList(textFile->text, strdup("no_name 0")); + list_add(textFile->text, strdup("no_name 0")); } - saveTextFile(textFile); + textFile_save(textFile); } -int addPlayerInHighScore(char *name, int score) +int table_add(char *name, int score) { int i; @@ -59,10 +59,10 @@ int addPlayerInHighScore(char *name, int score) char new[STR_SIZE]; sprintf(new, "%s %d", name, score); - insList(textFile->text, i, strdup(new)); - delListItem(textFile->text, HIGHSCORE_MAX_PLAYERS, free); - //printTextFile(textFile); - saveTextFile(textFile); + list_ins(textFile->text, i, strdup(new)); + list_del_item(textFile->text, HIGHSCORE_MAX_PLAYERS, free); + //textFile_print(textFile); + textFile_save(textFile); return 0; } @@ -71,7 +71,7 @@ int addPlayerInHighScore(char *name, int score) return -1; } -char *getTableItem(int index) +char *highScore_get_table(int index) { if (textFile != NULL && index >= 0 && index < textFile->text->count) { return (char *) textFile->text->list[index]; @@ -80,10 +80,10 @@ char *getTableItem(int index) return NULL; } -void quitHighScore() +void highScore_quit() { if (textFile != NULL) { - saveTextFile(textFile); - destroyTextFile(textFile); + textFile_save(textFile); + textFile_destroy(textFile); } } diff --git a/src/server/highScore.h b/src/server/highScore.h index 8c3c141..7326d6d 100644 --- a/src/server/highScore.h +++ b/src/server/highScore.h @@ -5,9 +5,9 @@ # define HIGHSCORE_MAX_PLAYERS 100 -extern void initHighScore(char *file); -extern int addPlayerInHighScore(char *name, int score); -extern char *getTableItem(int index); -extern void quitHighScore(); +extern void highScore_init(char *file); +extern int table_add(char *name, int score); +extern char *highScore_get_table(int index); +extern void highScore_quit(); #endif diff --git a/src/server/log.c b/src/server/log.c index 67a25f8..fcfb6e0 100644 --- a/src/server/log.c +++ b/src/server/log.c @@ -11,7 +11,7 @@ static FILE *logFile; -int initLog(char *name) +int log_init(char *name) { logFile = fopen(name, "a"); @@ -22,12 +22,12 @@ int initLog(char *name) DEBUG_MSG(_("I use logfile: \"%s\")\n"), name); - addToLog(LOG_INF, "open log file"); + log_add(LOG_INF, "open log file"); return 0; } -void addToLog(int type, char *msg) +void log_add(int type, char *msg) { char str[STR_LOG_SIZE]; struct tm *tm_struct; @@ -65,8 +65,8 @@ void addToLog(int type, char *msg) fflush(logFile); } -void quitLog() +void log_quit() { - addToLog(LOG_INF, "close log file"); + log_add(LOG_INF, "close log file"); fclose(logFile); } diff --git a/src/server/log.h b/src/server/log.h index 01f2c8b..6b61529 100644 --- a/src/server/log.h +++ b/src/server/log.h @@ -8,8 +8,8 @@ # define LOG_WRN 3 # define LOG_ERR 4 -extern int initLog(char *name); -extern void addToLog(int type, char *msg); -extern void quitLog(); +extern int log_init(char *name); +extern void log_add(int type, char *msg); +extern void log_quit(); #endif diff --git a/src/server/publicServer.c b/src/server/publicServer.c index ccf044f..475c47d 100644 --- a/src/server/publicServer.c +++ b/src/server/publicServer.c @@ -47,13 +47,13 @@ extern int errno; #define __PACKED__ __attribute__ ((__packed__)) -void countRoundInc() +void word_inc_round() { } -char *getSetting(char *env, char *param, char *default_val) +char *publicServer_get_setting(char *env, char *param, char *default_val) { - return getParamElse(param, getServerConfigFileValue(env, default_val)); + return getParamElse(param, server_configFile_get_value(env, default_val)); } static int registerPublicServer() @@ -68,7 +68,7 @@ static int registerPublicServer() struct sockaddr_in server; char *master_server_ip; - master_server_ip = getIPFormDNS(NET_MASTER_SERVER_DOMAIN); + master_server_ip = gns_resolv(NET_MASTER_SERVER_DOMAIN); //printf("master_server_ip = %s\n", master_server_ip); @@ -161,7 +161,7 @@ static int registerPublicServer() register_head *head = (register_head *) str; head->cmd = 'p'; - head->port = atoi(getSetting("PORT4", "--port4", "6800")); + head->port = atoi(publicServer_get_setting("PORT4", "--port4", "6800")); head->ip = 0; // TODO /* send request for server list */ @@ -186,7 +186,7 @@ static int registerPublicServer() return 0; } -static int initPublicServerNetwork() +static int publicServer_initNetwork() { char ip4[STR_IP_SIZE]; char ip6[STR_IP_SIZE]; @@ -197,8 +197,8 @@ static int initPublicServerNetwork() ret = -1; - strcpy(ip4, getSetting("IP4", "--ip4", "none")); - strcpy(ip6, getSetting("IP6", "--ip6", "none")); + strcpy(ip4, publicServer_get_setting("IP4", "--ip4", "none")); + strcpy(ip6, publicServer_get_setting("IP6", "--ip6", "none")); p_ip4 = ip4; @@ -212,68 +212,68 @@ static int initPublicServerNetwork() p_ip6 = NULL; } - port4 = atoi(getSetting("PORT4", "--port4", "6800")); - port6 = atoi(getSetting("PORT6", "--port6", "6800")); + port4 = atoi(publicServer_get_setting("PORT4", "--port4", "6800")); + port6 = atoi(publicServer_get_setting("PORT6", "--port6", "6800")); //ret = initNetMulitplayerPublicServer(p_ip4, port4, p_ip6, port6); - ret = initNetMuliplayerForGameServer(p_ip4, port4, p_ip6, port6); + ret = netMultiplayer_init_for_game_server(p_ip4, port4, p_ip6, port6); return ret; } -static void loadArena() +static void load_arena() { - choice_arenaFile = getArenaFileFormNetName(getSetting("ARENA", "--arena", "FAGN")); + choice_arenaFile = arenaFile_get_file_format_net_name(publicServer_get_setting("ARENA", "--arena", "FAGN")); if (choice_arenaFile == NULL) { - fprintf(stderr, _("I dont load arena %s!\n"), getSetting("ARENA", "--arena", "FAGN")); + fprintf(stderr, _("I dont load arena %s!\n"), publicServer_get_setting("ARENA", "--arena", "FAGN")); exit(-1); } - arena = getArena(choice_arenaFile); + arena = arenaFile_get_arena(choice_arenaFile); - setCurrentArena(arena); + arena_set_current(arena); } -int initPublicServer() +int publicServer_init() { int ret; int i; - initListID(); - initModule(); - initArenaFile(); - initTux(); - initItem(); - initShot(); - initServerConfigFile(); + id_init_list(); + module_init(); + arenaFile_init(); + tux_init(); + item_init(); + shot_init(); + server_configFile_init(); - ret = initLog(getSetting("LOG_FILE", "--log-file", "/tmp/tuxanci-server.log")); + ret = log_init(publicServer_get_setting("LOG_FILE", "--log-file", "/tmp/tuxanci-server.log")); if (ret < 0) { fprintf(stderr, _("I was unable to open config file!\n")); return -1; } - initHighScore(getSetting("SCORE_FILE", "--score-file", "/tmp/highscore.txt")); + highScore_init(publicServer_get_setting("SCORE_FILE", "--score-file", "/tmp/highscore.txt")); - loadArena(); + load_arena(); - for (i = 0; i < atoi(getSetting("ITEM", "--item", "10")); i++) { - addNewItem(arena->spaceItem, ID_UNKNOWN); + for (i = 0; i < atoi(publicServer_get_setting("ITEM", "--item", "10")); i++) { + item_add_new_item(arena->spaceItem, ID_UNKNOWN); } isSignalEnd = FALSE; - ret = initPublicServerNetwork(); + ret = publicServer_initNetwork(); if (ret < 0) { printf(_("Unable to initialize network socket!\n")); return -1; } - setServerMaxClients(atoi (getSetting("MAX_CLIENTS", "--max-clients", "32"))); + server_set_max_clients(atoi (publicServer_get_setting("MAX_CLIENTS", "--max-clients", "32"))); if (registerPublicServer() < 0) { printf(_("Unable to contact MasterServer!)\n")); @@ -282,7 +282,7 @@ int initPublicServer() return 0; } -arenaFile_t *getChoiceArena() +arenaFile_t *choiceArena_get() { return choice_arenaFile; } @@ -292,26 +292,26 @@ void eventPublicServer() static my_time_t lastActive = 0; my_time_t interval; - eventNetMultiplayer(); + netMultiplayer_event(); if (isSignalEnd == TRUE) { - quitPublicServer(); + publicServer_quit(); } if (lastActive == 0) { - lastActive = getMyTime(); + lastActive = timer_get_current_time(); } - interval = getMyTime() - lastActive; + interval = timer_get_current_time() - lastActive; if (interval < 50) { return; } //printf("interval = %d\n", interval); - lastActive = getMyTime(); + lastActive = timer_get_current_time(); - eventArena(arena); + arena_event(arena); } void my_handler_quit(int n) @@ -321,36 +321,36 @@ void my_handler_quit(int n) isSignalEnd = TRUE; } -void quitPublicServer() +void publicServer_quit() { DEBUG_MSG(_("Quitting public server\n")); - quitNetMultiplayer(); - destroyArena(arena); + netMultiplayer_quit(); + arena_destroy(arena); - quitTux(); - quitItem(); - quitShot(); + tux_quit(); + item_quiy(); + shot_quit(); - quitArenaFile(); - quitServerConfigFile(); - quitModule(); - quitListID(); - quitHighScore(); - quitLog(); + arenaFile_quit(); + server_configFile_quit(); + module_quit(); + id_quit_list(); + highScore_quit(); + log_quit(); exit(0); } -int startPublicServer() +int publicServer_start() { #ifndef __WIN32__ signal(SIGINT, my_handler_quit); signal(SIGTERM, my_handler_quit); signal(SIGQUIT, my_handler_quit); #endif - if (initPublicServer() < 0) { - quitPublicServer(); + if (publicServer_init() < 0) { + publicServer_quit(); return -1; } diff --git a/src/server/publicServer.h b/src/server/publicServer.h index e5538b6..4a102a8 100644 --- a/src/server/publicServer.h +++ b/src/server/publicServer.h @@ -8,13 +8,13 @@ # define WORLD_COUNT_ROUND_UNLIMITED -1 -extern char *getSetting(char *env, char *param, char *default_val); -extern void countRoundInc(); -extern int initPublicServer(); -extern arenaFile_t *getChoiceArena(); +extern char *publicServer_get_setting(char *env, char *param, char *default_val); +extern void word_inc_round(); +extern int publicServer_init(); +extern arenaFile_t *choiceArena_get(); extern void eventPublicServer(); extern void my_handler_quit(int n); -extern void quitPublicServer(); -extern int startPublicServer(); +extern void publicServer_quit(); +extern int publicServer_start(); #endif diff --git a/src/server/serverConfigFile.c b/src/server/serverConfigFile.c index 0af58f9..e1331ab 100644 --- a/src/server/serverConfigFile.c +++ b/src/server/serverConfigFile.c @@ -32,7 +32,7 @@ static void prepareConfigFile(textFile_t * ts) } } -void initServerConfigFile() +void server_configFile_init() { char *configFile; @@ -40,7 +40,7 @@ void initServerConfigFile() printf(_("Loading configuration from: \"%s\"\n"), getParamElse("--config-file", SERVER_CONFIG)); - serverTextFile = loadTextFile(configFile); + serverTextFile = textFile_load(configFile); if (serverTextFile == NULL) { fprintf(stderr, @@ -68,7 +68,7 @@ static char *findValue(char *s) return NULL; } -char *getServerConfigFileValue(char *env, char *s) +char *server_configFile_get_value(char *env, char *s) { int i; int len; @@ -92,9 +92,9 @@ char *getServerConfigFileValue(char *env, char *s) return s; } -void quitServerConfigFile() +void server_configFile_quit() { if (serverTextFile != NULL) { - destroyTextFile(serverTextFile); + textFile_destroy(serverTextFile); } } diff --git a/src/server/serverConfigFile.h b/src/server/serverConfigFile.h index 221557b..4388df2 100644 --- a/src/server/serverConfigFile.h +++ b/src/server/serverConfigFile.h @@ -4,8 +4,8 @@ # define SERVER_CONFIG_FILE_H -extern void initServerConfigFile(); -extern char *getServerConfigFileValue(char *env, char *s); -extern void quitServerConfigFile(); +extern void server_configFile_init(); +extern char *server_configFile_get_value(char *env, char *s); +extern void server_configFile_quit(); #endif diff --git a/src/widget/widget.c b/src/widget/widget.c index b72a463..9cf2e7e 100644 --- a/src/widget/widget.c +++ b/src/widget/widget.c @@ -7,7 +7,7 @@ #include "widget.h" #include "widget_label.h" -widget_t *newWidget(int type, int x, int y, int w, int h, void *private_data) +widget_t *widget_new(int type, int x, int y, int w, int h, void *private_data) { widget_t *new; @@ -22,13 +22,13 @@ widget_t *newWidget(int type, int x, int y, int w, int h, void *private_data) return new; } -void widgetSetLocation(widget_t * p, int x, int y) +void widget_set_location(widget_t * p, int x, int y) { p->x = x; p->y = y; } -void widgetGetLocation(widget_t * p, int *x, int *y) +void widget_get_location(widget_t * p, int *x, int *y) { if (x != NULL) *x = p->x; @@ -37,13 +37,13 @@ void widgetGetLocation(widget_t * p, int *x, int *y) *y = p->y; } -void widgetSetSize(widget_t * p, int w, int h) +void widget_get_size(widget_t * p, int w, int h) { p->w = w; p->h = h; } -void widgetGetSize(widget_t * p, int *w, int *h) +void widget_set_size(widget_t * p, int *w, int *h) { if (w != NULL) *w = p->w; @@ -52,7 +52,7 @@ void widgetGetSize(widget_t * p, int *w, int *h) *h = p->h; } -void destroyWidget(widget_t * p) +void widget_destroy(widget_t * p) { free(p); } diff --git a/src/widget/widget.h b/src/widget/widget.h index c18a687..ad0f9a6 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -22,12 +22,12 @@ typedef struct widget_struct { void *private_data; } widget_t; -extern widget_t *newWidget(int type, int x, int y, int w, int h, +extern widget_t *widget_new(int type, int x, int y, int w, int h, void *private_data); -extern void widgetSetLocation(widget_t * p, int x, int y); -extern void widgetGetLocation(widget_t * p, int *x, int *y); -extern void widgetSetSize(widget_t * p, int w, int h); -extern void widgetGetSize(widget_t * p, int *w, int *h); -extern void destroyWidget(widget_t * p); +extern void widget_set_location(widget_t * p, int x, int y); +extern void widget_get_location(widget_t * p, int *x, int *y); +extern void widget_get_size(widget_t * p, int w, int h); +extern void widget_set_size(widget_t * p, int *w, int *h); +extern void widget_destroy(widget_t * p); #endif diff --git a/src/widget/widget_button.c b/src/widget/widget_button.c index ca1573a..f0031ce 100644 --- a/src/widget/widget_button.c +++ b/src/widget/widget_button.c @@ -11,20 +11,20 @@ #include "widget.h" #include "widget_button.h" -widget_t *newWidgetButton(char *text, int x, int y, void (*fce_event) (void *)) +widget_t *button_new(char *text, int x, int y, void (*fce_event) (void *)) { widget_button_t *new; new = malloc(sizeof(widget_button_t)); new->text = strdup(text); new->fce_event = fce_event; - getTextSize(text, &(new->w), &(new->h)); + font_text_size(text, &(new->w), &(new->h)); - return newWidget(WIDGET_TYPE_BUTTON, x, y, + return widget_new(WIDGET_TYPE_BUTTON, x, y, WIDGET_BUTTON_WIDTH, WIDGET_BUTTON_HEIGHT, new); } -void drawWidgetButton(widget_t * widget) +void button_draw(widget_t * widget) { widget_button_t *p; static image_t *g_button0 = NULL; @@ -35,30 +35,30 @@ void drawWidgetButton(widget_t * widget) assert(widget->type == WIDGET_TYPE_BUTTON); p = (widget_button_t *) widget->private_data; - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); if (g_button0 == NULL) { - g_button0 = addImageData("button0.png", IMAGE_ALPHA, "button0", IMAGE_GROUP_BASE); + g_button0 = image_add("button0.png", IMAGE_ALPHA, "button0", IMAGE_GROUP_BASE); } if (g_button1 == NULL) { g_button1 = - addImageData("button1.png", IMAGE_ALPHA, "button1", IMAGE_GROUP_BASE); + image_add("button1.png", IMAGE_ALPHA, "button1", IMAGE_GROUP_BASE); } if (x >= widget->x && x <= widget->x + WIDGET_BUTTON_WIDTH && y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT) { - drawImage(g_button1, widget->x, widget->y, 0, 0, g_button0->w, g_button0->h); + image_draw(g_button1, widget->x, widget->y, 0, 0, g_button0->w, g_button0->h); } else { - drawImage(g_button0, widget->x, widget->y, 0, 0, g_button0->w, g_button0->h); + image_draw(g_button0, widget->x, widget->y, 0, 0, g_button0->w, g_button0->h); } - //drawFont(p->text, p->x+WIDGET_BUTTON_WIDTH/2-p->w/2, p->y+p->h/2, COLOR_WHITE); - drawFont(p->text, widget->x + WIDGET_BUTTON_WIDTH / 2 - p->w / 2, + //font_draw(p->text, p->x+WIDGET_BUTTON_WIDTH/2-p->w/2, p->y+p->h/2, COLOR_WHITE); + font_draw(p->text, widget->x + WIDGET_BUTTON_WIDTH / 2 - p->w / 2, widget->y + WIDGET_BUTTON_HEIGHT / 2 - p->h / 2, COLOR_WHITE); } -void eventWidgetButton(widget_t * widget) +void button_event(widget_t * widget) { widget_button_t *p; static int my_time = 0; @@ -74,11 +74,11 @@ void eventWidgetButton(widget_t * widget) return; } - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); if (x >= widget->x && x <= widget->x + WIDGET_BUTTON_WIDTH && y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT && - isMouseClicked()) { + interface_is_mouse_clicket()) { my_time = WIDGET_BUTTON_TIME; DEBUG_MSG(_("Event caught\n")); @@ -87,7 +87,7 @@ void eventWidgetButton(widget_t * widget) } } -void destroyWidgetButton(widget_t * widget) +void button_destroy(widget_t * widget) { widget_button_t *p; @@ -99,5 +99,5 @@ void destroyWidgetButton(widget_t * widget) free(p->text); free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_button.h b/src/widget/widget_button.h index ac238be..a42e35c 100644 --- a/src/widget/widget_button.h +++ b/src/widget/widget_button.h @@ -17,10 +17,10 @@ typedef struct widget_button { void (*fce_event) (void *); } widget_button_t; -extern widget_t *newWidgetButton(char *text, int x, int y, +extern widget_t *button_new(char *text, int x, int y, void (*fce_event) (void *)); -extern void drawWidgetButton(widget_t * widget); -extern void eventWidgetButton(widget_t * widget); -extern void destroyWidgetButton(widget_t * widget); +extern void button_draw(widget_t * widget); +extern void button_event(widget_t * widget); +extern void button_destroy(widget_t * widget); #endif diff --git a/src/widget/widget_buttonimage.c b/src/widget/widget_buttonimage.c index a896142..a924c5d 100644 --- a/src/widget/widget_buttonimage.c +++ b/src/widget/widget_buttonimage.c @@ -10,7 +10,7 @@ #include "widget.h" #include "widget_buttonimage.h" -widget_t *newWidgetButtonimage(image_t * image, int x, int y, void (*fce_event) (void *)) +widget_t *buttonImage_new(image_t * image, int x, int y, void (*fce_event) (void *)) { widget_buttonimage_t *new; @@ -21,10 +21,10 @@ widget_t *newWidgetButtonimage(image_t * image, int x, int y, void (*fce_event) new->active = 0; new->fce_event = fce_event; - return newWidget(WIDGET_TYPE_BUTTONIMAGE, x, y, new->w, new->h, new); + return widget_new(WIDGET_TYPE_BUTTONIMAGE, x, y, new->w, new->h, new); } -void setWidgetButtonimageActive(widget_t * widget, bool_t active) +void buttonImage_set_active(widget_t * widget, bool_t active) { widget_buttonimage_t *p; @@ -35,7 +35,7 @@ void setWidgetButtonimageActive(widget_t * widget, bool_t active) p->active = active; } -void drawWidgetButtonimage(widget_t * widget) +void buttonImage_draw(widget_t * widget) { widget_buttonimage_t *p; @@ -43,10 +43,10 @@ void drawWidgetButtonimage(widget_t * widget) assert(widget->type == WIDGET_TYPE_BUTTONIMAGE); p = (widget_buttonimage_t *) widget->private_data; - drawImage(p->image, widget->x, widget->y, p->active * p->w, 0, p->w, p->h); + image_draw(p->image, widget->x, widget->y, p->active * p->w, 0, p->w, p->h); } -void eventWidgetButtonimage(widget_t * widget) +void buttonImage_event(widget_t * widget) { widget_buttonimage_t *p; static int my_time = 0; @@ -62,17 +62,17 @@ void eventWidgetButtonimage(widget_t * widget) return; } - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); if (x >= widget->x && x <= widget->x + p->w && - y >= widget->y && y <= widget->y + p->h && isMouseClicked()) { + y >= widget->y && y <= widget->y + p->h && interface_is_mouse_clicket()) { my_time = WIDGET_BUTTONIMAGE_TIME; p->active = 1; p->fce_event(widget); } } -void destroyWidgetButtonimage(widget_t * widget) +void buttonImage_destroy(widget_t * widget) { widget_buttonimage_t *p; @@ -82,5 +82,5 @@ void destroyWidgetButtonimage(widget_t * widget) p = (widget_buttonimage_t *) widget->private_data; free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_buttonimage.h b/src/widget/widget_buttonimage.h index 5a0ab7c..2b05fe6 100644 --- a/src/widget/widget_buttonimage.h +++ b/src/widget/widget_buttonimage.h @@ -16,12 +16,12 @@ typedef struct widget_buttonimageimage { void (*fce_event) (void *); } widget_buttonimage_t; -extern widget_t *newWidgetButtonimage(image_t * image, int x, int y, +extern widget_t *buttonImage_new(image_t * image, int x, int y, void (*fce_event) (void *)); -extern void setWidgetButtonimageActive(widget_t * widget, bool_t active); -extern void drawWidgetButtonimage(widget_t * widget); -extern void eventWidgetButtonimage(widget_t * widget); -extern void destroyWidgetButtonimage(widget_t * widget); +extern void buttonImage_set_active(widget_t * widget, bool_t active); +extern void buttonImage_draw(widget_t * widget); +extern void buttonImage_event(widget_t * widget); +extern void buttonImage_destroy(widget_t * widget); #endif diff --git a/src/widget/widget_catchkey.c b/src/widget/widget_catchkey.c index b213890..6e1268c 100644 --- a/src/widget/widget_catchkey.c +++ b/src/widget/widget_catchkey.c @@ -9,7 +9,7 @@ #include "widget.h" #include "widget_catchkey.h" -widget_t *newWidgetCatchkey(int key, int x, int y, void *event) +widget_t *catchKey_new(int key, int x, int y, void *event) { widget_catchkey_t *new; @@ -18,10 +18,10 @@ widget_t *newWidgetCatchkey(int key, int x, int y, void *event) new->fce_event = event; new->active = FALSE; - return newWidget(WIDGET_TYPE_CATCHKEY, x, y, WIDGET_CATCHKEY_WIDTH, WIDGET_CATCHKEY_HEIGHT, new); + return widget_new(WIDGET_TYPE_CATCHKEY, x, y, WIDGET_CATCHKEY_WIDTH, WIDGET_CATCHKEY_HEIGHT, new); } -int getWidgetCatchKey(widget_t * widget) +int catchKey_get(widget_t * widget) { widget_catchkey_t *p; @@ -33,7 +33,7 @@ int getWidgetCatchKey(widget_t * widget) return p->key; } -void setWidgetCatchKey(widget_t * widget, int key) +void catchKey_set(widget_t * widget, int key) { widget_catchkey_t *p; @@ -45,7 +45,7 @@ void setWidgetCatchKey(widget_t * widget, int key) p->key = key; } -void drawWidgetCatchkey(widget_t * widget) +void catchKey_draw(widget_t * widget) { widget_catchkey_t *p; char *name; @@ -65,9 +65,9 @@ void drawWidgetCatchkey(widget_t * widget) } if (p->active) { - drawFont(name, widget->x, widget->y, COLOR_RED); + font_draw(name, widget->x, widget->y, COLOR_RED); } else { - drawFont(name, widget->x, widget->y, COLOR_WHITE); + font_draw(name, widget->x, widget->y, COLOR_WHITE); } } @@ -93,7 +93,7 @@ static int getPessAnyKey() return WIDGET_CATCHKEY_NOKEY; } -void eventWidgetCatchkey(widget_t * widget) +void catchKey_event(widget_t * widget) { widget_catchkey_t *p; int x, y; @@ -103,9 +103,9 @@ void eventWidgetCatchkey(widget_t * widget) p = (widget_catchkey_t *) widget->private_data; - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); - if (isMouseClicked()) { + if (interface_is_mouse_clicket()) { if (x >= widget->x && x <= widget->x + WIDGET_CATCHKEY_WIDTH && y >= widget->y && y <= widget->y + WIDGET_CATCHKEY_HEIGHT) { p->active = TRUE; @@ -126,7 +126,7 @@ void eventWidgetCatchkey(widget_t * widget) } } -void destroyWidgetCatchkey(widget_t * widget) +void catchKey_destroy(widget_t * widget) { widget_catchkey_t *p; @@ -136,5 +136,5 @@ void destroyWidgetCatchkey(widget_t * widget) p = (widget_catchkey_t *) widget->private_data; free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_catchkey.h b/src/widget/widget_catchkey.h index 106bc92..6a431e4 100644 --- a/src/widget/widget_catchkey.h +++ b/src/widget/widget_catchkey.h @@ -17,11 +17,11 @@ typedef struct widget_catchkey_struct { void (*fce_event) (void *p); } widget_catchkey_t; -extern widget_t *newWidgetCatchkey(int key, int x, int y, void *event); -extern int getWidgetCatchKey(widget_t * p); -extern void setWidgetCatchKey(widget_t * p, int key); -extern void drawWidgetCatchkey(widget_t * p); -extern void eventWidgetCatchkey(widget_t * p); -extern void destroyWidgetCatchkey(widget_t * p); +extern widget_t *catchKey_new(int key, int x, int y, void *event); +extern int catchKey_get(widget_t * p); +extern void catchKey_set(widget_t * p, int key); +extern void catchKey_draw(widget_t * p); +extern void catchKey_event(widget_t * p); +extern void catchKey_destroy(widget_t * p); #endif diff --git a/src/widget/widget_check.c b/src/widget/widget_check.c index e574211..07c5da5 100644 --- a/src/widget/widget_check.c +++ b/src/widget/widget_check.c @@ -9,7 +9,7 @@ #include "widget.h" #include "widget_check.h" -widget_t *newWidgetCheck(int x, int y, bool_t status, void (*fce_event) (void *)) +widget_t *check_new(int x, int y, bool_t status, void (*fce_event) (void *)) { widget_check_t *new; @@ -18,10 +18,10 @@ widget_t *newWidgetCheck(int x, int y, bool_t status, void (*fce_event) (void * new->status = status; new->fce_event = fce_event; - return newWidget(WIDGET_TYPE_CHECK, x, y, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT, new); + return widget_new(WIDGET_TYPE_CHECK, x, y, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT, new); } -void drawWidgetCheck(widget_t * widget) +void check_draw(widget_t * widget) { widget_check_t *p; static image_t *g_check = NULL; @@ -33,10 +33,10 @@ void drawWidgetCheck(widget_t * widget) p = (widget_check_t *) widget->private_data; - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); if (g_check == NULL) { - g_check = addImageData("check.png", IMAGE_ALPHA, "check", IMAGE_GROUP_BASE); + g_check = image_add("check.png", IMAGE_ALPHA, "check", IMAGE_GROUP_BASE); } if (p->status == TRUE) { @@ -45,10 +45,10 @@ void drawWidgetCheck(widget_t * widget) offset = WIDGET_CHECK_WIDTH; } - drawImage(g_check, widget->x, widget->y, offset, 0, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT); + image_draw(g_check, widget->x, widget->y, offset, 0, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT); } -void eventWidgetCheck(widget_t * widget) +void check_event(widget_t * widget) { widget_check_t *p; int x, y; @@ -63,11 +63,11 @@ void eventWidgetCheck(widget_t * widget) return; } - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); if (x >= widget->x && x <= widget->x + WIDGET_CHECK_WIDTH && y >= widget->y && y <= widget->y + WIDGET_CHECK_HEIGHT && - isMouseClicked()) { + interface_is_mouse_clicket()) { if (p->status == TRUE) { p->status = FALSE; p->time = WIDGET_CHECK_TIME_SWITCH_STATUS; @@ -82,7 +82,7 @@ void eventWidgetCheck(widget_t * widget) } } -bool_t getWidgetCheckStatus(widget_t * widget) +bool_t check_get_status(widget_t * widget) { widget_check_t *p; @@ -94,7 +94,7 @@ bool_t getWidgetCheckStatus(widget_t * widget) return p->status; } -void setWidgetCheckStatus(widget_t * widget, bool_t status) +void check_set_status(widget_t * widget, bool_t status) { widget_check_t *p; @@ -105,7 +105,7 @@ void setWidgetCheckStatus(widget_t * widget, bool_t status) p->status = status; } -void destroyWidgetCheck(widget_t * widget) +void check_destroy(widget_t * widget) { widget_check_t *p; @@ -114,5 +114,5 @@ void destroyWidgetCheck(widget_t * widget) p = (widget_check_t *) widget->private_data; free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_check.h b/src/widget/widget_check.h index 007e82c..5969541 100644 --- a/src/widget/widget_check.h +++ b/src/widget/widget_check.h @@ -17,12 +17,12 @@ typedef struct widget_check { void (*fce_event) (void *); } widget_check_t; -extern widget_t *newWidgetCheck(int x, int y, bool_t status, +extern widget_t *check_new(int x, int y, bool_t status, void (*fce_event) (void *)); -extern void drawWidgetCheck(widget_t * widget); -extern void eventWidgetCheck(widget_t * widget); -extern bool_t getWidgetCheckStatus(widget_t * widget); -extern void setWidgetCheckStatus(widget_t * widget, bool_t status); -extern void destroyWidgetCheck(widget_t * widget); +extern void check_draw(widget_t * widget); +extern void check_event(widget_t * widget); +extern bool_t check_get_status(widget_t * widget); +extern void check_set_status(widget_t * widget, bool_t status); +extern void check_destroy(widget_t * widget); #endif diff --git a/src/widget/widget_choicegroup.c b/src/widget/widget_choicegroup.c index 5173164..700c043 100644 --- a/src/widget/widget_choicegroup.c +++ b/src/widget/widget_choicegroup.c @@ -9,7 +9,7 @@ #include "widget.h" #include "widget_choicegroup.h" -widget_t *newWidgetChoicegroup(int x, int y, bool_t status, list_t * list, void (*fce_event) (void *)) +widget_t *choiceGroup_new(int x, int y, bool_t status, list_t * list, void (*fce_event) (void *)) { widget_choicegroup_t *new; widget_t *widget; @@ -20,14 +20,14 @@ widget_t *newWidgetChoicegroup(int x, int y, bool_t status, list_t * list, void new->fce_event = fce_event; new->list = list; - widget = newWidget(WIDGET_TYPE_CHOICE, x, y, WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT, new); + widget = widget_new(WIDGET_TYPE_CHOICE, x, y, WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT, new); - addList(new->list, widget); + list_add(new->list, widget); return widget; } -void drawWidgetChoicegroup(widget_t * widget) +void choiceGroup_draw(widget_t * widget) { widget_choicegroup_t *p; static image_t *g_choicegroup = NULL; @@ -39,10 +39,10 @@ void drawWidgetChoicegroup(widget_t * widget) p = (widget_choicegroup_t *) widget->private_data; - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); if (g_choicegroup == NULL) { - g_choicegroup = addImageData("choice.png", IMAGE_ALPHA, "choicegroup", IMAGE_GROUP_BASE); + g_choicegroup = image_add("choice.png", IMAGE_ALPHA, "choicegroup", IMAGE_GROUP_BASE); } if (p->status == TRUE) { @@ -51,11 +51,11 @@ void drawWidgetChoicegroup(widget_t * widget) offset = WIDGET_CHOICEGROUP_WIDTH; } - drawImage(g_choicegroup, widget->x, widget->y, offset, 0, + image_draw(g_choicegroup, widget->x, widget->y, offset, 0, WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT); } -void setWidgetChoiceActive(widget_t * widget) +void choiceGroup_set_active(widget_t * widget) { widget_choicegroup_t *p; int i; @@ -82,7 +82,7 @@ void setWidgetChoiceActive(widget_t * widget) } } -bool_t getWidgetChoiceStatus(widget_t * widget) +bool_t choiceGroup_get_status(widget_t * widget) { widget_choicegroup_t *p; @@ -94,7 +94,7 @@ bool_t getWidgetChoiceStatus(widget_t * widget) return p->status; } -void setWidgetChoiceStatus(widget_t * widget, bool_t status) +void choiceGroup_set_status(widget_t * widget, bool_t status) { widget_choicegroup_t *p; @@ -105,7 +105,7 @@ void setWidgetChoiceStatus(widget_t * widget, bool_t status) p->status = status; } -void eventWidgetChoicegroup(widget_t * widget) +void choiceGroup_event(widget_t * widget) { widget_choicegroup_t *p; int x, y; @@ -120,16 +120,16 @@ void eventWidgetChoicegroup(widget_t * widget) return; } - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); if (x >= widget->x && x <= widget->x + WIDGET_CHOICEGROUP_WIDTH && y >= widget->y && y <= widget->y + WIDGET_CHOICEGROUP_HEIGHT && - isMouseClicked()) { - setWidgetChoiceActive(widget); + interface_is_mouse_clicket()) { + choiceGroup_set_active(widget); } } -void destroyWidgetChoicegroup(widget_t * widget) +void choiceGroup_destroy(widget_t * widget) { widget_choicegroup_t *p; int my_index; @@ -138,10 +138,10 @@ void destroyWidgetChoicegroup(widget_t * widget) assert(widget->type == WIDGET_TYPE_CHOICE); p = (widget_choicegroup_t *) widget->private_data; - my_index = searchListItem(p->list, widget); + my_index = list_search(p->list, widget); assert(my_index != -1); - delList(p->list, my_index); + list_del(p->list, my_index); free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_choicegroup.h b/src/widget/widget_choicegroup.h index a892d74..a74b0d8 100644 --- a/src/widget/widget_choicegroup.h +++ b/src/widget/widget_choicegroup.h @@ -19,15 +19,15 @@ typedef struct widget_choicegroup { list_t *list; } widget_choicegroup_t; -extern widget_t *newWidgetChoicegroup(int x, int y, bool_t status, +extern widget_t *choiceGroup_new(int x, int y, bool_t status, list_t * list, void (*fce_event) (void *)); -extern void drawWidgetChoicegroup(widget_t * p); -extern void setWidgetChoiceActive(widget_t * widget); -extern bool_t getWidgetChoiceStatus(widget_t * widget); -extern void setWidgetChoiceStatus(widget_t * widget, bool_t status); -extern void eventWidgetChoicegroup(widget_t * p); -extern void destroyWidgetChoicegroup(widget_t * p); +extern void choiceGroup_draw(widget_t * p); +extern void choiceGroup_set_active(widget_t * widget); +extern bool_t choiceGroup_get_status(widget_t * widget); +extern void choiceGroup_set_status(widget_t * widget, bool_t status); +extern void choiceGroup_event(widget_t * p); +extern void choiceGroup_destroy(widget_t * p); #endif diff --git a/src/widget/widget_image.c b/src/widget/widget_image.c index ad49f9e..ed07cb0 100644 --- a/src/widget/widget_image.c +++ b/src/widget/widget_image.c @@ -11,17 +11,17 @@ #include "widget.h" #include "widget_image.h" -widget_t *newWidgetImage(int x, int y, image_t * image) +widget_t *wid_image_new(int x, int y, image_t * image) { widget_image_t *new; new = malloc(sizeof(widget_image_t)); new->image = image; - return newWidget(WIDGET_TYPE_IMAGE, x, y, image->w, image->h, new); + return widget_new(WIDGET_TYPE_IMAGE, x, y, image->w, image->h, new); } -void drawWidgetImage(widget_t * widget) +void wid_image_draw(widget_t * widget) { widget_image_t *p; @@ -29,16 +29,16 @@ void drawWidgetImage(widget_t * widget) assert(widget->type == WIDGET_TYPE_IMAGE); p = (widget_image_t *) widget->private_data; - drawImage(p->image, widget->x, widget->y, 0, 0, p->image->w, p->image->h); + image_draw(p->image, widget->x, widget->y, 0, 0, p->image->w, p->image->h); } -void eventWidgetImage(widget_t * widget) +void wid_image_event(widget_t * widget) { assert(widget != NULL); assert(widget->type == WIDGET_TYPE_IMAGE); } -void destroyWidgetImage(widget_t * widget) +void wid_image_destroy(widget_t * widget) { widget_image_t *p; @@ -48,5 +48,5 @@ void destroyWidgetImage(widget_t * widget) p = (widget_image_t *) widget->private_data; free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_image.h b/src/widget/widget_image.h index 081fbda..2af63e6 100644 --- a/src/widget/widget_image.h +++ b/src/widget/widget_image.h @@ -11,9 +11,9 @@ typedef struct widget_image { image_t *image; } widget_image_t; -extern widget_t *newWidgetImage(int x, int y, image_t * image); -extern void drawWidgetImage(widget_t * p); -extern void eventWidgetImage(widget_t * p); -extern void destroyWidgetImage(widget_t * p); +extern widget_t *wid_image_new(int x, int y, image_t * image); +extern void wid_image_draw(widget_t * p); +extern void wid_image_event(widget_t * p); +extern void wid_image_destroy(widget_t * p); #endif diff --git a/src/widget/widget_label.c b/src/widget/widget_label.c index e3c907c..8ef7fad 100644 --- a/src/widget/widget_label.c +++ b/src/widget/widget_label.c @@ -8,19 +8,19 @@ #include "widget_label.h" #include "widget.h" -widget_t *newWidgetLabel(char *text, int x, int y, int bind) +widget_t *label_new(char *text, int x, int y, int bind) { widget_label_t *new; new = malloc(sizeof(widget_label_t)); new->text = strdup(text); new->bind = bind; - getTextSize(text, &(new->w), &(new->h)); + font_text_size(text, &(new->w), &(new->h)); - return newWidget(WIDGET_TYPE_LABEL, x, y, new->w, new->h, new); + return widget_new(WIDGET_TYPE_LABEL, x, y, new->w, new->h, new); } -void drawWidgetLabel(widget_t * widget) +void label_draw(widget_t * widget) { widget_label_t *p; @@ -31,24 +31,24 @@ void drawWidgetLabel(widget_t * widget) switch (p->bind) { case WIDGET_LABEL_RIGHT: - drawFont(p->text, widget->x + p->w, widget->y + p->h / 2, COLOR_WHITE); + font_draw(p->text, widget->x + p->w, widget->y + p->h / 2, COLOR_WHITE); break; case WIDGET_LABEL_LEFT: - drawFont(p->text, widget->x, widget->y + widget->h / 2, COLOR_WHITE); + font_draw(p->text, widget->x, widget->y + widget->h / 2, COLOR_WHITE); break; case WIDGET_LABEL_CENTER: - drawFont(p->text, widget->x - p->w / 2, widget->y + p->h / 2, COLOR_WHITE); + font_draw(p->text, widget->x - p->w / 2, widget->y + p->h / 2, COLOR_WHITE); break; } } -void eventWidgetLabel(widget_t * widget) +void label_event(widget_t * widget) { assert(widget != NULL); assert(widget->type == WIDGET_TYPE_LABEL); } -void destroyWidgetLabel(widget_t * widget) +void label_destroy(widget_t * widget) { widget_label_t *p; @@ -60,5 +60,5 @@ void destroyWidgetLabel(widget_t * widget) free(p->text); free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_label.h b/src/widget/widget_label.h index 743db7e..a2c7a2a 100644 --- a/src/widget/widget_label.h +++ b/src/widget/widget_label.h @@ -16,9 +16,9 @@ typedef struct widget_label { # define WIDGET_LABEL_LEFT 2 # define WIDGET_LABEL_CENTER 3 -extern widget_t *newWidgetLabel(char *text, int x, int y, int bind); -extern void drawWidgetLabel(widget_t * widget); -extern void eventWidgetLabel(widget_t * widget); -extern void destroyWidgetLabel(widget_t * widget); +extern widget_t *label_new(char *text, int x, int y, int bind); +extern void label_draw(widget_t * widget); +extern void label_event(widget_t * widget); +extern void label_destroy(widget_t * widget); #endif diff --git a/src/widget/widget_select.c b/src/widget/widget_select.c index f53e583..88b22ac 100644 --- a/src/widget/widget_select.c +++ b/src/widget/widget_select.c @@ -9,19 +9,19 @@ #include "widget.h" #include "widget_select.h" -widget_t *newWidgetSelect(int x, int y, void (*fce_event) (void *)) +widget_t *select_new(int x, int y, void (*fce_event) (void *)) { widget_select_t *new; new = malloc(sizeof(widget_select_t)); new->select = -1; new->fce_event = fce_event; - new->list = newList(); + new->list = list_new(); - return newWidget(WIDGET_TYPE_SELECT, x, y, 0, 0, new); + return widget_new(WIDGET_TYPE_SELECT, x, y, 0, 0, new); } -char *getWidgetSelectItem(widget_t * widget) +char *select_get_item(widget_t * widget) { widget_select_t *p; @@ -37,7 +37,7 @@ char *getWidgetSelectItem(widget_t * widget) return (char *) p->list->list[p->select]; } -int getWidgetSelectIndex(widget_t * widget) +int select_get_index(widget_t * widget) { widget_select_t *p; @@ -49,7 +49,7 @@ int getWidgetSelectIndex(widget_t * widget) return p->select; } -void addToWidgetSelect(widget_t * widget, char *s) +void select_add(widget_t * widget, char *s) { widget_select_t *p; @@ -58,10 +58,10 @@ void addToWidgetSelect(widget_t * widget, char *s) p = (widget_select_t *) widget->private_data; - addList(p->list, strdup(s)); + list_add(p->list, strdup(s)); } -void removeAllFromWidgetSelect(widget_t * widget) +void select_remove_all(widget_t * widget) { widget_select_t *p; @@ -71,11 +71,11 @@ void removeAllFromWidgetSelect(widget_t * widget) p = (widget_select_t *) widget->private_data; while (p->list->count > 0) { - delListItem(p->list, 0, free); + list_del_item(p->list, 0, free); } } -void drawWidgetSelect(widget_t * widget) +void select_draw(widget_t * widget) { widget_select_t *p; int x, y, w, h; @@ -84,7 +84,7 @@ void drawWidgetSelect(widget_t * widget) assert(widget != NULL); assert(widget->type == WIDGET_TYPE_SELECT); - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); p = (widget_select_t *) widget->private_data; for (i = 0; i < p->list->count; i++) { @@ -92,22 +92,22 @@ void drawWidgetSelect(widget_t * widget) line = (char *) p->list->list[i]; - getTextSize(line, &w, &h); + font_text_size(line, &w, &h); if (x > widget->x && y > widget->y + i * 20 && x < widget->x + w && y < widget->y + i * 20 + h) { - drawFont(line, widget->x, widget->y + i * 20, COLOR_YELLOW); + font_draw(line, widget->x, widget->y + i * 20, COLOR_YELLOW); } else { if (p->select == i) { - drawFont(line, widget->x, widget->y + i * 20, COLOR_RED); + font_draw(line, widget->x, widget->y + i * 20, COLOR_RED); } else { - drawFont(line, widget->x, widget->y + i * 20, COLOR_WHITE); + font_draw(line, widget->x, widget->y + i * 20, COLOR_WHITE); } } } } -void eventWidgetSelect(widget_t * widget) +void select_event(widget_t * widget) { widget_select_t *p; int x, y, w, h; @@ -117,25 +117,25 @@ void eventWidgetSelect(widget_t * widget) assert(widget->type == WIDGET_TYPE_SELECT); p = (widget_select_t *) widget->private_data; - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); for (i = 0; i < p->list->count; i++) { char *line; line = (char *) p->list->list[i]; - getTextSize(line, &w, &h); + font_text_size(line, &w, &h); if (x > widget->x && y > widget->y + i * 20 && x < widget->x + w && y < widget->y + i * 20 + h && - isMouseClicked()) { + interface_is_mouse_clicket()) { p->select = i; p->fce_event(p); } } } -void destroyWidgetSelect(widget_t * widget) +void select_destroy(widget_t * widget) { widget_select_t *p; @@ -144,7 +144,7 @@ void destroyWidgetSelect(widget_t * widget) p = (widget_select_t *) widget->private_data; - destroyListItem(p->list, free); + list_destroy_item(p->list, free); free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_select.h b/src/widget/widget_select.h index 9d772cc..36a9890 100644 --- a/src/widget/widget_select.h +++ b/src/widget/widget_select.h @@ -14,13 +14,13 @@ typedef struct widget_select { void (*fce_event) (void *); } widget_select_t; -extern widget_t *newWidgetSelect(int x, int y, void (*fce_event) (void *)); -extern char *getWidgetSelectItem(widget_t * widget); -extern int getWidgetSelectIndex(widget_t * widget); -extern void addToWidgetSelect(widget_t * widget, char *s); -extern void removeAllFromWidgetSelect(widget_t * widget); -extern void drawWidgetSelect(widget_t * widget); -extern void eventWidgetSelect(widget_t * widget); -extern void destroyWidgetSelect(widget_t * widget); +extern widget_t *select_new(int x, int y, void (*fce_event) (void *)); +extern char *select_get_item(widget_t * widget); +extern int select_get_index(widget_t * widget); +extern void select_add(widget_t * widget, char *s); +extern void select_remove_all(widget_t * widget); +extern void select_draw(widget_t * widget); +extern void select_event(widget_t * widget); +extern void select_destroy(widget_t * widget); #endif diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c index 94fef18..07481b9 100644 --- a/src/widget/widget_textfield.c +++ b/src/widget/widget_textfield.c @@ -12,7 +12,7 @@ //#define ZZEEXX86_READKEY -widget_t *newWidgetTextfield(char *text, int filter, int x, int y) +widget_t *textField_new(char *text, int filter, int x, int y) { widget_textfield_t *new; @@ -25,9 +25,9 @@ widget_t *newWidgetTextfield(char *text, int filter, int x, int y) new->atime = 0; new->active = FALSE; new->filter = filter; - getTextSize(text, &new->w, &new->h); + font_text_size(text, &new->w, &new->h); - return newWidget(WIDGET_TYPE_TEXTFILED, x, y, + return widget_new(WIDGET_TYPE_TEXTFILED, x, y, WIDGET_TEXTFIELD_WIDTH, WIDGET_TEXTFIELD_HEIGHT, new); } @@ -43,17 +43,17 @@ static void drawBackground(widget_t * widget) p = (widget_textfield_t *) widget->private_data; if (g_textfield0 == NULL) { - g_textfield0 = addImageData("textfield0.png", IMAGE_ALPHA, "textfiled0", IMAGE_GROUP_BASE); + g_textfield0 = image_add("textfield0.png", IMAGE_ALPHA, "textfiled0", IMAGE_GROUP_BASE); } if (g_textfield1 == NULL) { - g_textfield1 = addImageData("textfield1.png", IMAGE_ALPHA, "textfiled1", IMAGE_GROUP_BASE); + g_textfield1 = image_add("textfield1.png", IMAGE_ALPHA, "textfiled1", IMAGE_GROUP_BASE); } if (p->active) { - drawImage(g_textfield1, widget->x, widget->y, 0, 0, g_textfield1->w, g_textfield1->h); + image_draw(g_textfield1, widget->x, widget->y, 0, 0, g_textfield1->w, g_textfield1->h); } else { - drawImage(g_textfield0, widget->x, widget->y, 0, 0, g_textfield0->w, g_textfield0->h); + image_draw(g_textfield0, widget->x, widget->y, 0, 0, g_textfield0->w, g_textfield0->h); } } @@ -81,14 +81,14 @@ static void drawText(widget_t * widget) p->timeBlick = 0; } - //drawFont(str, p->x+WIDGET_TEXTFIELD_TEXT_OFFSET_X, p->y+p->h/2, COLOR_WHITE); + //font_draw(str, p->x+WIDGET_TEXTFIELD_TEXT_OFFSET_X, p->y+p->h/2, COLOR_WHITE); //printf("p->y: %d\nheight: %d\n p->h: %d\n", p->y, WIDGET_TEXTFIELD_HEIGHT, p->h); - drawFont(str, widget->x + WIDGET_TEXTFIELD_TEXT_OFFSET_X, + font_draw(str, widget->x + WIDGET_TEXTFIELD_TEXT_OFFSET_X, widget->y + WIDGET_TEXTFIELD_HEIGHT / 2 - p->h / 2, COLOR_WHITE); } -void drawWidgetTextfield(widget_t * widget) +void textField_draw(widget_t * widget) { assert(widget != NULL); assert(widget->type == WIDGET_TYPE_TEXTFILED); @@ -97,7 +97,7 @@ void drawWidgetTextfield(widget_t * widget) drawText(widget); } -void setWidgetTextFiledText(widget_t * widget, char *text) +void textField_set_text(widget_t * widget, char *text) { widget_textfield_t *p; @@ -108,10 +108,10 @@ void setWidgetTextFiledText(widget_t * widget, char *text) memset(p->text, 0, STR_SIZE); strcpy(p->text, text); - getTextSize(text, &p->w, &p->h); + font_text_size(text, &p->w, &p->h); } -char *getTextFromWidgetTextfield(widget_t * widget) +char *textField_get_text(widget_t * widget) { widget_textfield_t *p; @@ -177,7 +177,7 @@ static void checkText(widget_textfield_t * p) } } - getTextSize(p->text, &p->w, &p->h); + font_text_size(p->text, &p->w, &p->h); } #ifdef ZZEEXX86_READKEY @@ -204,7 +204,7 @@ static void readKey(widget_textfield_t * p) if (len > 0) { p->time = 0; p->text[len - 1] = '\0'; - getTextSize(p->text, &p->w, &p->h); + font_text_size(p->text, &p->w, &p->h); } return; @@ -406,7 +406,7 @@ static void readKey(widget_textfield_t * p) } #endif -void eventWidgetTextfield(widget_t * widget) +void textField_event(widget_t * widget) { widget_textfield_t *p; int x, y; @@ -416,9 +416,9 @@ void eventWidgetTextfield(widget_t * widget) p = (widget_textfield_t *) widget->private_data; - getMousePosition(&x, &y); + interface_get_mouse_position(&x, &y); - if (isMouseClicked()) { + if (interface_is_mouse_clicket()) { if (x >= widget->x && x <= widget->x + WIDGET_TEXTFIELD_WIDTH && y >= widget->y && y <= widget->y + WIDGET_TEXTFIELD_HEIGHT) { p->active = TRUE; @@ -430,7 +430,7 @@ void eventWidgetTextfield(widget_t * widget) readKey(p); } -void destroyWidgetTextfield(widget_t * widget) +void textField_destroy(widget_t * widget) { widget_textfield_t *p; @@ -440,5 +440,5 @@ void destroyWidgetTextfield(widget_t * widget) p = (widget_textfield_t *) widget->private_data; free(p); - destroyWidget(widget); + widget_destroy(widget); } diff --git a/src/widget/widget_textfield.h b/src/widget/widget_textfield.h index 7991deb..7f8e198 100644 --- a/src/widget/widget_textfield.h +++ b/src/widget/widget_textfield.h @@ -31,11 +31,11 @@ typedef struct widget_textfield { bool_t active; } widget_textfield_t; -extern widget_t *newWidgetTextfield(char *text, int filter, int x, int y); -extern void setWidgetTextFiledText(widget_t * widget, char *text); -extern char *getTextFromWidgetTextfield(widget_t * widget); -extern void drawWidgetTextfield(widget_t * widget); -extern void eventWidgetTextfield(widget_t * widget); -extern void destroyWidgetTextfield(widget_t * widget); +extern widget_t *textField_new(char *text, int filter, int x, int y); +extern void textField_set_text(widget_t * widget, char *text); +extern char *textField_get_text(widget_t * widget); +extern void textField_draw(widget_t * widget); +extern void textField_event(widget_t * widget); +extern void textField_destroy(widget_t * widget); #endif |