Skip to content

Commit

Permalink
Merge pull request #16368 from codemime/extend_generic_factory
Browse files Browse the repository at this point in the history
[RDY] Extend 'generic_factory' + aliases + use the factory to manage terrain objects
  • Loading branch information
Coolthulhu committed Apr 28, 2016
2 parents 1353153 + 056052b commit 053b449
Show file tree
Hide file tree
Showing 23 changed files with 433 additions and 359 deletions.
52 changes: 52 additions & 0 deletions data/json/terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,10 @@
},{
"type" : "terrain",
"id" : "t_wall",
"aliases" : [
"t_wall_h",
"t_wall_v"
],
"name": "wall",
"symbol": "LINE_OXOX",
"color": "ltgray",
Expand All @@ -974,6 +978,10 @@
},{
"type" : "terrain",
"id" : "t_concrete_wall",
"aliases" : [
"t_concrete_h",
"t_concrete_v"
],
"name": "concrete wall",
"symbol": "LINE_OXOX",
"color": "dkgray",
Expand All @@ -993,6 +1001,10 @@
},{
"type" : "terrain",
"id" : "t_wall_metal",
"aliases" : [
"t_wall_metal_h",
"t_wall_metal_v"
],
"name": "metal wall",
"symbol": "LINE_OXOX",
"color": "cyan",
Expand All @@ -1013,6 +1025,10 @@
},{
"type" : "terrain",
"id" : "t_wall_glass",
"aliases" : [
"t_wall_glass_h",
"t_wall_glass_v"
],
"name": "glass wall",
"symbol": "LINE_OXOX",
"color": "ltcyan",
Expand All @@ -1032,6 +1048,10 @@
},{
"type" : "terrain",
"id" : "t_wall_glass_alarm",
"aliases" : [
"t_wall_glass_h_alarm",
"t_wall_glass_v_alarm"
],
"name": "glass wall",
"symbol": "LINE_OXOX",
"color": "ltcyan",
Expand All @@ -1052,6 +1072,10 @@
},{
"type" : "terrain",
"id" : "t_reinforced_glass",
"aliases" : [
"t_reinforced_glass_h",
"t_reinforced_glass_v"
],
"name": "reinforced glass",
"symbol": "LINE_OXOX",
"color": "ltcyan",
Expand Down Expand Up @@ -3786,6 +3810,10 @@
},{
"type" : "terrain",
"id" : "t_fungus_wall",
"aliases" : [
"t_fungus_wall_h",
"t_fungus_wall_v"
],
"name": "fungal wall",
"symbol": "O",
"color": "dkgray",
Expand Down Expand Up @@ -5137,6 +5165,10 @@
},{
"type" : "terrain",
"id" : "t_wall_r",
"aliases" : [
"t_wall_h_r",
"t_wall_v_r"
],
"name": "red wall",
"symbol": "LINE_OXOX",
"color": "red",
Expand All @@ -5152,6 +5184,10 @@
},{
"type" : "terrain",
"id" : "t_wall_w",
"aliases" : [
"t_wall_h_w",
"t_wall_v_w"
],
"name": "white wall",
"symbol": "LINE_OXOX",
"color": "white",
Expand All @@ -5167,6 +5203,10 @@
},{
"type" : "terrain",
"id" : "t_wall_b",
"aliases" : [
"t_wall_h_b",
"t_wall_v_b"
],
"name": "blue wall",
"symbol": "LINE_OXOX",
"color": "blue",
Expand All @@ -5182,6 +5222,10 @@
},{
"type" : "terrain",
"id" : "t_wall_g",
"aliases" : [
"t_wall_h_g",
"t_wall_v_g"
],
"name": "green wall",
"symbol": "LINE_OXOX",
"color": "green",
Expand All @@ -5197,6 +5241,10 @@
},{
"type" : "terrain",
"id" : "t_wall_y",
"aliases" : [
"t_wall_h_y",
"t_wall_v_y"
],
"name": "yellow wall",
"symbol": "LINE_OXOX",
"color": "yellow",
Expand All @@ -5212,6 +5260,10 @@
},{
"type" : "terrain",
"id" : "t_wall_p",
"aliases" : [
"t_wall_h_p",
"t_wall_v_p"
],
"name": "purple wall",
"symbol": "LINE_OXOX",
"color": "magenta",
Expand Down
2 changes: 2 additions & 0 deletions data/mods/No_Fungi/terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"type" : "terrain",
"id" : "t_marloss",
"edit-mode" : "override",
"name": "marloss bush",
"symbol": "#",
"color": "dkgray",
Expand All @@ -16,6 +17,7 @@
},{
"type" : "terrain",
"id" : "t_marloss_tree",
"edit-mode" : "override",
"name": "marloss tree",
"symbol": "7",
"color": "dkgray",
Expand Down
2 changes: 1 addition & 1 deletion lua/class_definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ classes = {

attributes = {
close = { type = "ter_str_id", writable = true },
harvest_season = { type = "int", writable = true },
harvest_season = { type = "season_type", writable = true },
harvestable = { type = "string", writable = true },
name = { type = "string", writable = false },
open = { type = "ter_str_id", writable = true },
Expand Down
4 changes: 2 additions & 2 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2727,8 +2727,8 @@ void cata_tiles::do_tile_loading_report() {
//TODO: exclude fake items from Item_factory::init_old()
tile_loading_report(item_controller->get_all_itypes(), "Items", "");
auto mtypes = MonsterGenerator::generator().get_all_mtypes();
lr_generic( mtypes.begin(), mtypes.end(), []( std::vector<const mtype *>::iterator m ) {
return ( *m )->id.str();
lr_generic( mtypes.begin(), mtypes.end(), []( const std::vector<mtype>::iterator &m ) {
return ( *m ).id.str();
}, "Monsters", "" );
tile_loading_report<vpart_info>(vpart_info::get_all().size(), "Vehicle Parts", "vp_");
tile_loading_report<trap>(trap::count(), "Traps", "");
Expand Down
4 changes: 2 additions & 2 deletions src/catalua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ static int game_get_item_groups(lua_State *L)
// monster_types = game.get_monster_types()
static int game_get_monster_types(lua_State *L)
{
std::vector<const mtype *> mtypes = MonsterGenerator::generator().get_all_mtypes();
const auto mtypes = MonsterGenerator::generator().get_all_mtypes();

lua_createtable(L, mtypes.size(), 0); // Preallocate enough space for all our monster types.

Expand All @@ -992,7 +992,7 @@ static int game_get_monster_types(lua_State *L)
// lua_rawset then does t[k] = v and pops v and k from the stack

lua_pushnumber(L, i + 1);
LuaValue<mtype_id>::push( L, mtypes[i]->id );
LuaValue<mtype_id>::push( L, mtypes[i].id );
lua_rawset(L, -3);
}

Expand Down
2 changes: 1 addition & 1 deletion src/defense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void defense_game::game_over()
void defense_game::init_mtypes()
{
for( auto &type : MonsterGenerator::generator().get_all_mtypes() ) {
mtype *const t = const_cast<mtype *>( type );
mtype *const t = const_cast<mtype *>( &type );
t->difficulty *= 1.5;
t->difficulty += int( t->difficulty / 5 );
t->flags.insert( MF_BASHES );
Expand Down
4 changes: 2 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,8 @@ bool game::cleanup_at_end()
int iTotalKills = 0;

for( const auto &type : MonsterGenerator::generator().get_all_mtypes() ) {
if( kill_count( type->id ) > 0 ) {
iTotalKills += kill_count( type->id );
if( kill_count( type.id ) > 0 ) {
iTotalKills += kill_count( type.id );
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/gates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ using gate_id = string_id<gate_data>;
struct gate_data {

gate_data() :
wall( NULL_ID ),
door( NULL_ID ),
floor( NULL_ID ),
wall(),
door(),
floor(),
moves( 0 ),
bash_dmg( 0 ),
was_loaded( false ) {};
Expand Down
Loading

0 comments on commit 053b449

Please sign in to comment.