Fixed missing new-line in light serialization and a bug caused by checking eof in scene files

dev
shariq 8 years ago
parent 4774e83133
commit d565295ea9
  1. 3
      README.md
  2. 2
      src/libsymmetry/entity.c
  3. 10
      src/libsymmetry/scene.c

@ -151,7 +151,6 @@
- Add camera fbo params into camera struct so they can be saved and loaded into file - Add camera fbo params into camera struct so they can be saved and loaded into file
- Finish loading scene from file - Finish loading scene from file
- Fix space not being added after some entities are written to file
- Update makefiles to be able to compile the code in it's current state - Update makefiles to be able to compile the code in it's current state
- Find a solution for the asset import/export situation by either updating the blender exporter or adding assimp as dependancy - Find a solution for the asset import/export situation by either updating the blender exporter or adding assimp as dependancy
- Fix bugs with sound sources not updating - Fix bugs with sound sources not updating
@ -313,3 +312,5 @@
* Made dll reloading workaround compatilble on linux * Made dll reloading workaround compatilble on linux
* Default keybindings as fallback * Default keybindings as fallback
* Implemented writing scene to file * Implemented writing scene to file
* Fixed space not being added after light entities are written to file by adding missing new-line
* Fixed error caused by the way eof was checked in scene file

@ -261,7 +261,7 @@ bool entity_write(struct Entity* entity, FILE* file)
fprintf(file, "valid: %s\n", entity->light.valid ? "true" : "false"); fprintf(file, "valid: %s\n", entity->light.valid ? "true" : "false");
fprintf(file, "cast_shadow: %s\n", entity->light.cast_shadow ? "true" : "false"); fprintf(file, "cast_shadow: %s\n", entity->light.cast_shadow ? "true" : "false");
fprintf(file, "pcf_enabled: %s\n", entity->light.pcf_enabled ? "true" : "false"); fprintf(file, "pcf_enabled: %s\n", entity->light.pcf_enabled ? "true" : "false");
fprintf(file, "color: %.5f %.5f %.5f", fprintf(file, "color: %.5f %.5f %.5f\n",
entity->light.color.x, entity->light.color.x,
entity->light.color.y, entity->light.color.y,
entity->light.color.z); entity->light.color.z);

@ -132,18 +132,26 @@ bool scene_load(const char* filename, int directory_type)
} }
int count = 0; int count = 0;
int eof_char = -1;
while(!feof(entity_file)) while(!feof(entity_file))
{ {
if(eof_char != -1) ungetc(eof_char, entity_file);
struct Entity* new_entity = NULL; struct Entity* new_entity = NULL;
new_entity = entity_read(entity_file); new_entity = entity_read(entity_file);
if(!new_entity) if(!new_entity)
{
log_error("scene:load", "Error reading entity"); log_error("scene:load", "Error reading entity");
}
else else
{ {
log_message("Loaded %s", new_entity->name); log_message("Loaded %s", new_entity->name);
count++; count++;
} }
int c = fgetc(entity_file); eof_char = fgetc(entity_file);
/* To check end of file, we get the next character and before beginning
loop we check if eof occured, feof only returns true if the last read
was an eof. If it wasn't eof then we return the character back to the
stream and carry on. */
} }
log_message("%d entites loaded from %s", count, filename); log_message("%d entites loaded from %s", count, filename);

Loading…
Cancel
Save