Add make format rule
This commit is contained in:
+2
-1
@@ -2,4 +2,5 @@
|
|||||||
/librefront
|
/librefront
|
||||||
/librefront-headless
|
/librefront-headless
|
||||||
/perf.data*
|
/perf.data*
|
||||||
/massif.out*
|
/massif.out*
|
||||||
|
/*~
|
||||||
@@ -41,7 +41,7 @@ SERVER_LDFLAGS := $(COMMON_LDFLAGS)
|
|||||||
CLIENT := librefront
|
CLIENT := librefront
|
||||||
SERVER := librefront-headless
|
SERVER := librefront-headless
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean format
|
||||||
|
|
||||||
all: $(CLIENT) $(SERVER)
|
all: $(CLIENT) $(SERVER)
|
||||||
|
|
||||||
@@ -66,6 +66,11 @@ build/server/%.o: $(SRC_DIR)/server/%.c
|
|||||||
clean:
|
clean:
|
||||||
$(RM) -r build/ $(CLIENT) $(SERVER) perf.data* massif.out*
|
$(RM) -r build/ $(CLIENT) $(SERVER) perf.data* massif.out*
|
||||||
|
|
||||||
|
format:
|
||||||
|
find $(SRC_DIR) -type f \( -name '*.c' -o -name '*.h' \) \
|
||||||
|
-exec sh -c 'tmp=$$(mktemp) || tmp=/tmp/indent.$$$$; \
|
||||||
|
indent -gnu "$$1" -o "$$tmp" && mv "$$tmp" "$$1"' _ {} \;
|
||||||
|
|
||||||
-include $(COMMON_DEP)
|
-include $(COMMON_DEP)
|
||||||
-include $(CLIENT_DEP)
|
-include $(CLIENT_DEP)
|
||||||
-include $(SERVER_DEP)
|
-include $(SERVER_DEP)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ pkgs.mkShellNoCC {
|
|||||||
glib
|
glib
|
||||||
|
|
||||||
gcc
|
gcc
|
||||||
|
indent
|
||||||
pkg-config
|
pkg-config
|
||||||
cloc
|
cloc
|
||||||
valgrind
|
valgrind
|
||||||
|
|||||||
+3
-3
@@ -48,7 +48,7 @@ SDL_AppInit (void **appstate, int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_SetAppMetadata (GAME_NAME, GAME_VERSION, GAME_URL);
|
SDL_SetAppMetadata (GAME_NAME, GAME_VERSION, GAME_URL);
|
||||||
|
|
||||||
if (!SDL_Init (SDL_INIT_VIDEO))
|
if (!SDL_Init (SDL_INIT_VIDEO))
|
||||||
{
|
{
|
||||||
g_error ("Couldn't initialize SDL: %s", SDL_GetError ());
|
g_error ("Couldn't initialize SDL: %s", SDL_GetError ());
|
||||||
@@ -63,7 +63,7 @@ SDL_AppResult
|
|||||||
SDL_AppEvent (void *appstate, SDL_Event *event)
|
SDL_AppEvent (void *appstate, SDL_Event *event)
|
||||||
{
|
{
|
||||||
UNUSED (appstate);
|
UNUSED (appstate);
|
||||||
|
|
||||||
if (event->type == SDL_EVENT_QUIT)
|
if (event->type == SDL_EVENT_QUIT)
|
||||||
{
|
{
|
||||||
return SDL_APP_SUCCESS;
|
return SDL_APP_SUCCESS;
|
||||||
@@ -79,7 +79,7 @@ SDL_AppIterate (void *appstate)
|
|||||||
|
|
||||||
GfxContext_prerender (gfx_ctx);
|
GfxContext_prerender (gfx_ctx);
|
||||||
GfxContext_postrender (gfx_ctx);
|
GfxContext_postrender (gfx_ctx);
|
||||||
|
|
||||||
return SDL_APP_CONTINUE;
|
return SDL_APP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,16 @@ GfxContext_new ()
|
|||||||
|
|
||||||
if (!self->window)
|
if (!self->window)
|
||||||
{
|
{
|
||||||
g_critical ("Couldn't create window for context %p: %s", self, SDL_GetError ());
|
g_critical ("Couldn't create window for context %p: %s", self,
|
||||||
|
SDL_GetError ());
|
||||||
}
|
}
|
||||||
|
|
||||||
self->renderer = SDL_CreateRenderer (self->window, NULL);
|
self->renderer = SDL_CreateRenderer (self->window, NULL);
|
||||||
|
|
||||||
if (!self->window)
|
if (!self->window)
|
||||||
{
|
{
|
||||||
g_critical ("Couldn't create renderer for context %p: %s", self, SDL_GetError ());
|
g_critical ("Couldn't create renderer for context %p: %s", self,
|
||||||
|
SDL_GetError ());
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ typedef struct GfxContext
|
|||||||
} GfxContext;
|
} GfxContext;
|
||||||
|
|
||||||
GfxContext *GfxContext_new ();
|
GfxContext *GfxContext_new ();
|
||||||
void GfxContext_prerender (GfxContext *self);
|
void GfxContext_prerender (GfxContext * self);
|
||||||
void GfxContext_postrender (GfxContext *self);
|
void GfxContext_postrender (GfxContext * self);
|
||||||
void GfxContext_free (GfxContext *self);
|
void GfxContext_free (GfxContext * self);
|
||||||
|
|
||||||
void GfxContext_renderWorld (GfxContext *self, World *world);
|
void GfxContext_renderWorld (GfxContext * self, World * world);
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ typedef struct Player
|
|||||||
unsigned int id;
|
unsigned int id;
|
||||||
const char *name;
|
const char *name;
|
||||||
SDL_Color color; /* 4 bytes */
|
SDL_Color color; /* 4 bytes */
|
||||||
|
|
||||||
unsigned int power;
|
unsigned int power;
|
||||||
unsigned int population, max_population;
|
unsigned int population, max_population;
|
||||||
|
|
||||||
gboolean is_alive : 1, is_human : 1;
|
gboolean is_alive:1, is_human:1;
|
||||||
} Player;
|
} Player;
|
||||||
|
|
||||||
typedef struct GameState
|
typedef struct GameState
|
||||||
@@ -26,4 +26,3 @@ typedef struct GameState
|
|||||||
GArray *players;
|
GArray *players;
|
||||||
Player *me;
|
Player *me;
|
||||||
} GameState;
|
} GameState;
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -3,12 +3,12 @@
|
|||||||
#include <glib-2.0/glib.h>
|
#include <glib-2.0/glib.h>
|
||||||
|
|
||||||
typedef enum TerrainType
|
typedef enum TerrainType
|
||||||
{
|
{
|
||||||
TERRAIN_WATER,
|
TERRAIN_WATER,
|
||||||
TERRAIN_FLAT,
|
TERRAIN_FLAT,
|
||||||
TERRAIN_HILL,
|
TERRAIN_HILL,
|
||||||
TERRAIN_MOUNTAIN
|
TERRAIN_MOUNTAIN
|
||||||
} TerrainType;
|
} TerrainType;
|
||||||
|
|
||||||
typedef struct MapTile
|
typedef struct MapTile
|
||||||
{
|
{
|
||||||
@@ -16,7 +16,7 @@ typedef struct MapTile
|
|||||||
unsigned int owner_id;
|
unsigned int owner_id;
|
||||||
TerrainType terrain_type;
|
TerrainType terrain_type;
|
||||||
|
|
||||||
gboolean is_defended : 1, is_radiated : 1;
|
gboolean is_defended:1, is_radiated:1;
|
||||||
} MapTile;
|
} MapTile;
|
||||||
|
|
||||||
typedef struct World
|
typedef struct World
|
||||||
@@ -27,14 +27,14 @@ typedef struct World
|
|||||||
} World;
|
} World;
|
||||||
|
|
||||||
|
|
||||||
typedef struct Building Building; // Typedef is needed to avoid circular dependency
|
typedef struct Building Building; // Typedef is needed to avoid circular dependency
|
||||||
struct Building
|
struct Building
|
||||||
{
|
{
|
||||||
MapTile *parent_tile;
|
MapTile *parent_tile;
|
||||||
unsigned int level;
|
unsigned int level;
|
||||||
|
|
||||||
unsigned int (*at_what_cost) (Building *self, World *world);
|
unsigned int (*at_what_cost) (Building * self, World * world);
|
||||||
};
|
};
|
||||||
|
|
||||||
World *World_new (unsigned int width, unsigned int height);
|
World *World_new (unsigned int width, unsigned int height);
|
||||||
void World_tick (World *self);
|
void World_tick (World * self);
|
||||||
|
|||||||
+3
-2
@@ -1,7 +1,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main ()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Server not implemented!\n");
|
fprintf (stderr, "Server not implemented!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user