Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 20a5edd3 authored by Florent Bouchez Tichadou's avatar Florent Bouchez Tichadou
Browse files

Merge branch 'fullgame' of gitlab.inria.fr:CORSE/agdbentures into fullgame

parents f9c746e7 ffb8d7a2
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ MAINPROG := main
OBJECTS := main.o map.o action.o common.o events.o events_map.o read_input.o
CC := gcc
CFLAGS := -g
CFLAGS := -g -Wall -Wextra
all: main
......
......@@ -10,7 +10,7 @@ int verify_exit(void)
}
}
void event_level_success(int trig) {
void event_level_success(__attribute__((unused)) int trig) {
level_success();
}
......@@ -57,7 +57,7 @@ int walks_on_water() {
return is_water(player_y, player_x);
}
void drown(int trig) {
void drown(__attribute__((unused)) int trig) {
printf("You drown!\n");
level_failed();
}
......@@ -8,7 +8,7 @@
int verify_exit(void);
// Fonction interne qui ne fait qu'appeler level_success
void event_level_success(int trig);
void event_level_success(__attribute__((unused)) int trig);
/* renvoie 0 si les 4 interrupteurs ne sont pas encore allumés,
1 s'ils sont allumés dans le bon ordre,
......@@ -22,6 +22,6 @@ void trap_door(int trig);
int walks_on_water();
// Le joueur se noie et level_failed est appelé
void drown(int trig);
void drown(__attribute__((unused)) int trig);
#endif // EVENTS_MAP_H
......@@ -63,7 +63,7 @@ void apply_input(Command * c) {
}
}
int main(int argc, char *argv[]) {
int main() {
CommandList inputs;
......
......@@ -187,7 +187,7 @@ void activate_switch(int y, int x) {
printf("You activate the %dth switch.\n", m->inter[i]->number);
char buffer[1];
char buffer[2];
sprintf(buffer, "%d", m->inter[i]->number);
strcat(played_order, buffer);
}
......@@ -13,7 +13,7 @@ int read_input_file(const char* filename, CommandList* commands) {
Command* prev_command = commands->command;
while (!feof(input_file)) {
size_t linesize = getline(&line, &command_length, input_file);
int linesize = getline(&line, &command_length, input_file);
if (linesize != -1) {
Command* next = allocate_command(line, linesize);
......@@ -49,6 +49,8 @@ Command* allocate_command(char* command_buffer, size_t buffer_len) {
// redo a pass to place args pointers
if (command->n_args > 0)
command->args = malloc(sizeof(char*) * command->n_args);
else
command->args = NULL;
int n_args = 0;
for (size_t current_char_index = 0; n_args < command->n_args; current_char_index++) {
if (command_buffer[current_char_index] == '\0') {
......@@ -64,14 +66,14 @@ Command* allocate_command(char* command_buffer, size_t buffer_len) {
void free_command(Command* command) {
// Free next commands
if (command->next != NULL) {
if (command->next != NULL)
free_command(command->next);
}
// Free current command
free(command->command_buffer); // Free the buffer allocated by getline
free(command->args);
if (command->args != NULL)
free(command->args);
}
void free_commands(CommandList* commands) {
free(commands->command);
free_command(commands->command);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment