Skip to content

Commit

Permalink
Markus Elfring requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
barbalet committed Feb 28, 2013
1 parent f17349d commit b5b577f
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 56 deletions.
15 changes: 9 additions & 6 deletions sim/entity/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
****************************************************************/

/*NOBLEMAKE DEL=""*/
#ifndef _NOBLEAPE_ENTITY_H_
#define _NOBLEAPE_ENTITY_H_
#ifndef NOBLEAPE_ENTITY_H
#define NOBLEAPE_ENTITY_H
/*NOBLEMAKE END=""*/

#define LAND_ON
Expand All @@ -55,9 +55,12 @@

#define EPISODIC_AFFECT_ZERO (16384)

#define BEING_HUNGRY (10*128)
#define BEING_FULL (BEING_HUNGRY*3)
#define BEING_STARVE (BEING_HUNGRY*2)
enum being_energy
{
BEING_HUNGRY = (10*128),
BEING_STARVE = (BEING_HUNGRY*2),
BEING_FULL = (BEING_HUNGRY*3)
};

#define SOCIAL_RESPECT_NORMAL 127

Expand Down Expand Up @@ -145,4 +148,4 @@ n_byte being_los(n_land * land, noble_being * local, n_byte2 lx, n_byte2
void speak_out(n_string filename, n_string paragraph);


#endif /* _NOBLEAPE_ENTITY_H_ */
#endif /* NOBLEAPE_ENTITY_H */
6 changes: 3 additions & 3 deletions sim/entity/entity_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
****************************************************************/

/*NOBLEMAKE DEL=""*/
#ifndef _NOBLEAPE_ENTITY_INTERNAL_H_
#define _NOBLEAPE_ENTITY_INTERNAL_H_
#ifndef NOBLEAPE_ENTITY_INTERNAL_H
#define NOBLEAPE_ENTITY_INTERNAL_H
/*NOBLEMAKE END=""*/

#define VISUAL_DISTANCE_SQUARED (4000*4000)
Expand Down Expand Up @@ -162,4 +162,4 @@ void being_ingest_pathogen(noble_being * local, n_byte food_type);

void watch_speech(void *ptr, n_string beingname, noble_being * local, n_string result);

#endif /* _NOBLEAPE_ENTITY_INTERNAL_H_ */
#endif /* NOBLEAPE_ENTITY_INTERNAL_H */
6 changes: 5 additions & 1 deletion sim/entity/speak.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ static void speak_make(n_string filename, n_string paragraph)
} while (found_character != '\n' && found_character != 0);


fclose(out_file);
if (fclose(out_file) != 0)
{
(void)SHOW_ERROR("Failed to close speak file");
}
return;
}

void speak_out(n_string filename, n_string paragraph)
Expand Down
6 changes: 3 additions & 3 deletions sim/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

/*NOBLEMAKE VAR=""*/

#ifndef _NOBLEAPE_GUI_H_
#define _NOBLEAPE_GUI_H_
#ifndef NOBLEAPE_GUI_H
#define NOBLEAPE_GUI_H

#define OFFSCREENSIZE (MAP_AREA + TERRAIN_WINDOW_AREA)

Expand Down Expand Up @@ -134,7 +134,7 @@ void draw_cycle(n_byte mod, n_int dim_x, n_int dim_y);

n_byte * draw_offscreen(n_byte * value);

#endif /* _NOBLEAPE_GUI_H_ */
#endif /* NOBLEAPE_GUI_H */

/*NOBLEMAKE END=""*/

Expand Down
6 changes: 3 additions & 3 deletions sim/gui/gui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
****************************************************************/

/*NOBLEMAKE DEL=""*/
#ifndef _NOBLEAPE_GUI_INTERNAL_H_
#define _NOBLEAPE_GUI_INTERNAL_H_
#ifndef NOBLEAPE_GUI_INTERNAL_H
#define NOBLEAPE_GUI_INTERNAL_H
/*NOBLEMAKE END=""*/


#endif /* _NOBLEAPE_ENTITY_INTERNAL_H_ */
#endif /* NOBLEAPE_ENTITY_INTERNAL_H */
6 changes: 3 additions & 3 deletions sim/gui/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

/*NOBLEMAKE VAR=""*/

#ifndef _NOBLEAPE_SHARED_H_
#define _NOBLEAPE_SHARED_H_
#ifndef NOBLEAPE_SHARED_H
#define NOBLEAPE_SHARED_H

void shared_cycle(n_uint ticks, n_int fIdentification);

Expand Down Expand Up @@ -101,7 +101,7 @@ n_int sim_thread_console_quit(void);

#endif

#endif /* _NOBLEAPE_SHARED_H_ */
#endif /* NOBLEAPE_SHARED_H */

/*NOBLEMAKE END=""*/

Expand Down
87 changes: 71 additions & 16 deletions sim/noble/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ n_int file_chain_write(n_string name, n_file_chain * initial)
local = (n_file_chain*)local->next;
} while (local != 0L);

fclose(write_file);
if (fclose(write_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return 0;
}

Expand All @@ -200,7 +203,10 @@ n_int file_chain_read(n_string name, n_file_chain * initial)
local = (n_file_chain*)local->next;
} while (local != 0L);

fclose(read_file);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return 0;
}

Expand All @@ -220,7 +226,10 @@ n_int file_chain_read_header(n_string name, n_file_chain * header, n_uint expect

if (header == 0L)
{
fclose(read_file);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return SHOW_ERROR("No header presented");
}

Expand All @@ -229,7 +238,10 @@ n_int file_chain_read_header(n_string name, n_file_chain * header, n_uint expect
header->data = io_new(expected_size);
if (header->data == 0L)
{
fclose(read_file);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return SHOW_ERROR("No hash allocated");
}
header->expected_bytes = expected_size;
Expand All @@ -239,15 +251,21 @@ n_int file_chain_read_header(n_string name, n_file_chain * header, n_uint expect
if (expected_size != actual_size)
{
io_free(hash_data);
fclose(read_file);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return SHOW_ERROR("File too short");
}
while (loop < expected_additional_entries)
{
header[loop+1].hash = hash_data[loop];
loop++;
}
fclose(read_file);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return 0;
}

Expand Down Expand Up @@ -275,7 +293,10 @@ n_int file_chain_read_validate(n_string name, n_file_chain *initial)
general_buffer = io_new(largest_bytes);
if (general_buffer == 0L)
{
fclose(read_file);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return SHOW_ERROR("Validation buffer not created");
}

Expand All @@ -284,7 +305,10 @@ n_int file_chain_read_validate(n_string name, n_file_chain *initial)

if (local == 0L)
{
fclose(read_file);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return SHOW_ERROR("File chain invalid");
}

Expand All @@ -293,8 +317,11 @@ n_int file_chain_read_validate(n_string name, n_file_chain *initial)
n_uint actual_hash;
if (actual_read != local->expected_bytes)
{
fclose(read_file);
io_free(general_buffer);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return SHOW_ERROR("File too short");
}

Expand All @@ -305,8 +332,11 @@ n_int file_chain_read_validate(n_string name, n_file_chain *initial)
if (actual_hash != local->hash)
{
n_string_block combination;
fclose(read_file);
io_free(general_buffer);
if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
sprintf(combination, "Hash failed (# %ld, actual %ld, expected %ld, bytes %ld, sizeof %ld)",count, actual_hash, local->hash, local->expected_bytes, sizeof(n_int));
return SHOW_ERROR(combination);
}
Expand All @@ -315,8 +345,13 @@ n_int file_chain_read_validate(n_string name, n_file_chain *initial)
count++;
} while (local != 0L);

fclose(read_file);
io_free(general_buffer);

if (fclose(read_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}

return 0;
}

Expand Down Expand Up @@ -468,7 +503,10 @@ n_int io_aiff_test(void * ptr, n_string response, n_console_output output_f

sprintf(output, "%ld\n",samples);
output_function(output);
fclose(test_file);
if (fclose(test_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
}
return 0;
}
Expand Down Expand Up @@ -619,7 +657,10 @@ n_int io_disk_read(n_file * local_file, n_string file_name)
}
}
}
fclose(in_file);
if (fclose(in_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}
return FILE_OKAY;
}

Expand Down Expand Up @@ -648,7 +689,12 @@ n_int io_disk_write(n_file * local_file, n_string file_name)
}

written_length = fwrite(local_file->data,1,local_file->location, out_file);
fclose(out_file);

if (fclose(out_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}

if (written_length != local_file->location)
{
return SHOW_ERROR("File did not complete write");
Expand All @@ -674,7 +720,12 @@ n_int io_disk_append(n_file * local_file, n_string file_name)
#endif

written_length = fwrite(local_file->data,1,local_file->location, out_file);
fclose(out_file);

if (fclose(out_file) != 0)
{
return SHOW_ERROR("File could not be closed");
}

if (written_length != local_file->location)
{
return SHOW_ERROR("File did not complete write");
Expand All @@ -700,7 +751,11 @@ n_int io_disk_check(n_string file_name)

if (local_check_file == 0L)
return 0;
fclose(local_check_file);

if (fclose(local_check_file) != 0)
{
return 0;
}
return 1;
}

Expand Down
6 changes: 4 additions & 2 deletions sim/noble/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,15 @@ static n_int parse_write_code(n_interpret * final_prog, n_byte value, n_byte cod
#endif
}


#ifdef ROUGH_CODE_OUT
if (value == ';' || value == '{' || value == '}')
{
fprintf(rough_code_file, "\n");
}
fclose(rough_code_file);
if (fclose(rough_code_file) != 0)
{
return SHOW_ERROR("File failed to close");
}
#endif
return 0;
}
Expand Down
35 changes: 19 additions & 16 deletions sim/universe/universe.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
****************************************************************/

/*NOBLEMAKE DEL=""*/
#ifndef _NOBLEAPE_UNIVERSE_H_
#define _NOBLEAPE_UNIVERSE_H_
#ifndef NOBLEAPE_UNIVERSE_H
#define NOBLEAPE_UNIVERSE_H
/*NOBLEMAKE END=""*/

/*NOBLEMAKE VAR=""*/
Expand Down Expand Up @@ -473,19 +473,22 @@ enum BODY_INVENTORY_TYPES
INVENTORY_SIZE
};

#define INVENTORY_CHILD 1
#define INVENTORY_WOUND 2
#define INVENTORY_GROOMED 4
#define INVENTORY_BRANCH 8
#define INVENTORY_ROCK 16
#define INVENTORY_SHELL 32
#define INVENTORY_TWIG 64
#define INVENTORY_NUT 128
#define INVENTORY_NUT_CRACKED 256
#define INVENTORY_GRASS 512
#define INVENTORY_SCRAPER 1024
#define INVENTORY_SPEAR 2048
#define INVENTORY_FISH 4096
enum inventory_type
{
INVENTORY_CHILD = 1,
INVENTORY_WOUND = 2,
INVENTORY_GROOMED = 4,
INVENTORY_BRANCH = 8,
INVENTORY_ROCK = 16,
INVENTORY_SHELL = 32,
INVENTORY_TWIG = 64,
INVENTORY_NUT = 128,
INVENTORY_NUT_CRACKED = 256,
INVENTORY_GRASS = 512,
INVENTORY_SCRAPER = 1024,
INVENTORY_SPEAR = 2048,
INVENTORY_FISH = 4096
};

#define VALUABLE_OBJECT (INVENTORY_NUT & INVENTORY_SHELL)

Expand Down Expand Up @@ -1749,7 +1752,7 @@ const static noble_console_command control_commands[] =
/*NOBLEMAKE DEL=""*/


#endif /* _NOBLEAPE_UNIVERSE_H_ */
#endif /* NOBLEAPE_UNIVERSE_H */

/*NOBLEMAKE END=""*/

Expand Down
Loading

0 comments on commit b5b577f

Please sign in to comment.