diff options
Diffstat (limited to 'src/base')
57 files changed, 1180 insertions, 1180 deletions
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 |