Skip to content

Commit

Permalink
Change line endings not excluded in .gitattributes to LF.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrBrd committed Jul 30, 2018
1 parent 69c727c commit 71de039
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 130 deletions.
24 changes: 12 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4 space indentation
indent_style = space
indent_size = 4
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4 space indentation
indent_style = space
indent_size = 4
194 changes: 97 additions & 97 deletions src/recipe_groups.cpp
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
#include "recipe_groups.h"
#include "game.h" // TODO: This is a circular dependency
#include "generic_factory.h"
#include "player.h"
#include "output.h"
#include "messages.h"
#include "json.h"

#include <string>
#include <algorithm>
#include <vector>

// recipe_groups namespace

namespace
{

struct recipe_group_data;
using group_id = string_id<recipe_group_data>;

struct recipe_group_data {
group_id id;
std::string building_type = "NONE";
std::map<std::string, std::string> cooking_recipes;
bool was_loaded;

void load( JsonObject &jo, const std::string &src );
void check() const;
};

generic_factory<recipe_group_data> recipe_groups_data( "recipe group type", "name",
"other_handles" );

} // namespace

void recipe_group_data::load( JsonObject &jo, const std::string & )
{
building_type = jo.get_string( "building_type" );
JsonArray jsarr;
jsarr = jo.get_array( "recipes" );
while( jsarr.has_more() ) {
JsonObject ordering = jsarr.next_object();
std::string name_id = ordering.get_string( "id" );
std::string desc = ordering.get_string( "description" );
cooking_recipes[desc] = name_id;
}

}

void recipe_group_data::check() const
{
for( auto a : cooking_recipes ) {
if( !recipe_id( a.second ).is_valid() ) {
debugmsg( "%s is not a valid recipe", a.second );
}
}
}

std::map<std::string, std::string> recipe_group::get_recipes( std::string id )
{
std::map<std::string, std::string> all_rec;
if( id == "ALL" ) {
for( auto gr : recipe_groups_data.get_all() ) {
std::map<std::string, std::string> tmp = gr.cooking_recipes;
all_rec.insert( tmp.begin(), tmp.end() );
}
return all_rec;
} else if( id == "COOK" || id == "BASE" || id == "FARM" || id == "SMITH" ) {
for( auto gr : recipe_groups_data.get_all() ) {
if( gr.building_type != id ) {
continue;
}
std::map<std::string, std::string> tmp = gr.cooking_recipes;
all_rec.insert( tmp.begin(), tmp.end() );
}
return all_rec;
}
if( !recipe_groups_data.is_valid( group_id( id ) ) ) {
return all_rec;
}
const recipe_group_data &group = recipe_groups_data.obj( group_id( id ) );
return group.cooking_recipes;
}
void recipe_group::load( JsonObject &jo, const std::string &src )
{
recipe_groups_data.load( jo, src );
}

void recipe_group::check()
{
recipe_groups_data.check();
}

void recipe_group::reset()
{
recipe_groups_data.reset();
}
#include "recipe_groups.h"
#include "game.h" // TODO: This is a circular dependency
#include "generic_factory.h"
#include "player.h"
#include "output.h"
#include "messages.h"
#include "json.h"

#include <string>
#include <algorithm>
#include <vector>

// recipe_groups namespace

namespace
{

struct recipe_group_data;
using group_id = string_id<recipe_group_data>;

struct recipe_group_data {
group_id id;
std::string building_type = "NONE";
std::map<std::string, std::string> cooking_recipes;
bool was_loaded;

void load( JsonObject &jo, const std::string &src );
void check() const;
};

generic_factory<recipe_group_data> recipe_groups_data( "recipe group type", "name",
"other_handles" );

} // namespace

void recipe_group_data::load( JsonObject &jo, const std::string & )
{
building_type = jo.get_string( "building_type" );
JsonArray jsarr;
jsarr = jo.get_array( "recipes" );
while( jsarr.has_more() ) {
JsonObject ordering = jsarr.next_object();
std::string name_id = ordering.get_string( "id" );
std::string desc = ordering.get_string( "description" );
cooking_recipes[desc] = name_id;
}

}

void recipe_group_data::check() const
{
for( auto a : cooking_recipes ) {
if( !recipe_id( a.second ).is_valid() ) {
debugmsg( "%s is not a valid recipe", a.second );
}
}
}

std::map<std::string, std::string> recipe_group::get_recipes( std::string id )
{
std::map<std::string, std::string> all_rec;
if( id == "ALL" ) {
for( auto gr : recipe_groups_data.get_all() ) {
std::map<std::string, std::string> tmp = gr.cooking_recipes;
all_rec.insert( tmp.begin(), tmp.end() );
}
return all_rec;
} else if( id == "COOK" || id == "BASE" || id == "FARM" || id == "SMITH" ) {
for( auto gr : recipe_groups_data.get_all() ) {
if( gr.building_type != id ) {
continue;
}
std::map<std::string, std::string> tmp = gr.cooking_recipes;
all_rec.insert( tmp.begin(), tmp.end() );
}
return all_rec;
}
if( !recipe_groups_data.is_valid( group_id( id ) ) ) {
return all_rec;
}
const recipe_group_data &group = recipe_groups_data.obj( group_id( id ) );
return group.cooking_recipes;
}
void recipe_group::load( JsonObject &jo, const std::string &src )
{
recipe_groups_data.load( jo, src );
}

void recipe_group::check()
{
recipe_groups_data.check();
}

void recipe_group::reset()
{
recipe_groups_data.reset();
}
42 changes: 21 additions & 21 deletions src/recipe_groups.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#include "map.h"
#pragma once
#ifndef RECIPE_GROUPS_H
#define RECIPE_GROUPS_H

#include <string>

class JsonObject;

namespace recipe_group
{

void load( JsonObject &jo, const std::string &src );
void check();
void reset();

std::map<std::string, std::string> get_recipes( std::string id );

};

#endif
#include "map.h"
#pragma once
#ifndef RECIPE_GROUPS_H
#define RECIPE_GROUPS_H

#include <string>

class JsonObject;

namespace recipe_group
{

void load( JsonObject &jo, const std::string &src );
void check();
void reset();

std::map<std::string, std::string> get_recipes( std::string id );

};

#endif

0 comments on commit 71de039

Please sign in to comment.