diff options
| author | xHire <xhire@tuxportal.cz> | 2008-10-25 14:11:06 +0200 |
|---|---|---|
| committer | xHire <xhire@tuxportal.cz> | 2008-10-25 14:11:06 +0200 |
| commit | c8a9209d77a896bf49227e5aeccd54e91ccf29cc (patch) | |
| tree | 6b7367406ebbc6ce3ea5e0c8668c75f6fb3f6ae9 /src/client/radar.c | |
| parent | cb9deba915dd7b114eeb76601eb1c8b07c1ba90f (diff) | |
Changed style of the code to the K&R standard
Diffstat (limited to 'src/client/radar.c')
| -rw-r--r-- | src/client/radar.c | 136 |
1 files changed, 64 insertions, 72 deletions
diff --git a/src/client/radar.c b/src/client/radar.c index ade5599..990f8cb 100644 --- a/src/client/radar.c +++ b/src/client/radar.c @@ -15,112 +15,104 @@ static image_t *g_radar; static list_t *listRadar; -typedef struct radar_item_struct -{ - int id; - int x, y; - int type; +typedef struct radar_item_struct { + int id; + int x, y; + int type; } radar_item_t; -static radar_item_t * -newRadarItem(int id, int x, int y, int type) +static radar_item_t *newRadarItem(int id, int x, int y, int type) { - radar_item_t *new; + radar_item_t *new; - new = malloc(sizeof(radar_item_t)); - new->id = id; - new->x = x; - new->y = y; - new->type = type; + new = malloc(sizeof(radar_item_t)); + new->id = id; + new->x = x; + new->y = y; + new->type = type; - return new; + return new; } -static void -destroyRadarItem(radar_item_t * p) +static void destroyRadarItem(radar_item_t * p) { - assert(p != NULL); - free(p); + assert(p != NULL); + free(p); } -void -addToRadar(int id, int x, int y, int type) +void addToRadar(int id, int x, int y, int type) { - int i; + int i; - for (i = 0; i < listRadar->count; i++) { - radar_item_t *thisRadarItem; + for (i = 0; i < listRadar->count; i++) { + radar_item_t *thisRadarItem; - thisRadarItem = (radar_item_t *) listRadar->list[i]; + thisRadarItem = (radar_item_t *) listRadar->list[i]; - if (thisRadarItem->id == id) { - thisRadarItem->x = x; - thisRadarItem->y = y; - thisRadarItem->type = type; - return; - } - } + if (thisRadarItem->id == id) { + thisRadarItem->x = x; + thisRadarItem->y = y; + thisRadarItem->type = type; + return; + } + } - addList(listRadar, newRadarItem(id, x, y, type)); + addList(listRadar, newRadarItem(id, x, y, type)); } -void -delFromRadar(int id) +void delFromRadar(int id) { - int i; + int i; - for (i = 0; i < listRadar->count; i++) { - radar_item_t *thisRadarItem; + for (i = 0; i < listRadar->count; i++) { + radar_item_t *thisRadarItem; - thisRadarItem = (radar_item_t *) listRadar->list[i]; + thisRadarItem = (radar_item_t *) listRadar->list[i]; - if (thisRadarItem->id == id) { - delListItem(listRadar, i, destroyRadarItem); - return; - } - } + if (thisRadarItem->id == id) { + delListItem(listRadar, i, destroyRadarItem); + return; + } + } } -void -initRadar() +void initRadar() { - assert(isImageInicialized() == TRUE); - assert(isInterfaceInicialized() == TRUE); + assert(isImageInicialized() == TRUE); + assert(isInterfaceInicialized() == TRUE); - g_radar = - addImageData("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER); - listRadar = newList(); + g_radar = + addImageData("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER); + listRadar = newList(); } -void -drawRadar(arena_t * arena) +void drawRadar(arena_t * arena) { - int i; + int i; - drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0, - RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2); + drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0, + RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2); - for (i = 0; i < listRadar->count; i++) { - radar_item_t *thisRadarItem; - int x, y; + for (i = 0; i < listRadar->count; i++) { + radar_item_t *thisRadarItem; + int x, y; - thisRadarItem = (radar_item_t *) listRadar->list[i]; + thisRadarItem = (radar_item_t *) listRadar->list[i]; - x = (((float) RADAR_SIZE_X) / ((float) arena->w)) * - ((float) thisRadarItem->x); - y = (((float) RADAR_SIZE_Y) / ((float) arena->h)) * - ((float) thisRadarItem->y); + x = (((float) RADAR_SIZE_X) / ((float) arena->w)) * + ((float) thisRadarItem->x); + y = (((float) RADAR_SIZE_Y) / ((float) arena->h)) * + ((float) thisRadarItem->y); - if (x >= 0 && x <= RADAR_SIZE_X && y >= 0 && y <= RADAR_SIZE_Y) { - drawImage(g_radar, - RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y, - 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2); - } - } + if (x >= 0 && x <= RADAR_SIZE_X && y >= 0 && y <= RADAR_SIZE_Y) { + drawImage(g_radar, + RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y, + 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2); + } + } } -void -quitRadar() +void quitRadar() { - destroyListItem(listRadar, destroyRadarItem); + destroyListItem(listRadar, destroyRadarItem); } |