diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/commandbuffer.cc | 26 | ||||
| -rw-r--r-- | src/core/entity.cc | 20 | ||||
| -rw-r--r-- | src/core/entity.h | 7 | ||||
| -rw-r--r-- | src/core/item.h | 16 | ||||
| -rw-r--r-- | src/core/parser.cc | 2 | 
5 files changed, 64 insertions, 7 deletions
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc index 3c7fc35..40971cc 100644 --- a/src/core/commandbuffer.cc +++ b/src/core/commandbuffer.cc @@ -116,6 +116,22 @@ void func_list_ent(std::string const &args)  	Entity::list();  } +void func_list_inventory(std::string const &args) +{ +	unsigned long id; +	std::istringstream argstream(args); +	if (argstream >> id) { +		Entity *entity = Entity::find(id); +		if (entity) { +			entity->list_inventory(); +		} else { +			con_print << "Could not find entity with id " << id << std::endl; +		}		 +	} else { +		con_print << "usage: list_inventory [entity id]" <<  std::endl; +	} +} +  void func_list_zone(std::string const &args)  {  	Zone *zone = Zone::search(args); @@ -142,7 +158,7 @@ void func_set(std::string const &args)  	std::istringstream argstream(args);  	std::string varname;  	if (!(argstream >> varname)) { -		con_print << "Variable name expected!"  << std::endl; +		con_print << "usage: set [variable name]" <<  std::endl;  		return;  	} @@ -174,7 +190,7 @@ void func_toggle(std::string const &args)  	std::istringstream argstream(args);  	std::string varname;  	if (!(argstream >> varname)) { -		con_print << "Variable name expected!"  << std::endl; +		con_print << "usage: toggle [variable name]" <<  std::endl;  		return;  	} @@ -242,6 +258,9 @@ void CommandBuffer::init()  	func = Func::add("list_info", (FuncPtr)func_list_info);  	func->set_info("list info records"); +	func = Func::add("list_inventory", (FuncPtr)func_list_inventory); +	func->set_info("[entity id] list entity inventories"); +  	func = Func::add("list_var", (FuncPtr)func_list_var);  	func->set_info("list variables"); @@ -249,7 +268,7 @@ void CommandBuffer::init()  	func->set_info("list zones");  	Func::add("list_model", (FuncPtr) func_list_model); -	func->set_info("list models"); +	func->set_info("list 3d models");  	Func::add("list_module", (FuncPtr) func_list_module);  	func->set_info("list game modules"); @@ -282,6 +301,7 @@ void CommandBuffer::shutdown()  	Func::remove("list_var");  	Func::remove("list_func");  	Func::remove("list_info"); +	Func::remove("list_inventories");  	Func::remove("list_ent");  	Func::remove("list_model");  	Func::remove("list_module"); diff --git a/src/core/entity.cc b/src/core/entity.cc index fdcce59..538aecb 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -401,6 +401,26 @@ void Entity::remove_menu(std::string const &label)  	}  } +void Entity::list_inventory() const +{ +	con_print << "  ^B" << name() << "^N "; +	if (!entity_inventory) { +		con_print << "no inventory availble" << std::endl; +		return; +	} +	con_print << "inventory" << std::endl; +	 +	for (Inventory::Items::const_iterator it = entity_inventory->items().begin(); it != entity_inventory->items().end(); it++) { +		Item *item = (*it); +		con_print << " "  +			  << " ^B" << std::setw(4) << item->info()->id() +			  << " ^N" << (item->info()->type() ? item->info()->type()->label() : "NULL") +			  << " ^N" << item->info()->label() +			  << " amount " << item->amount() << std::endl; +	} +	 +} +  /* ---- class EntityDynamic ---------------------------------------- */  EntityDynamic::EntityDynamic() : Entity() diff --git a/src/core/entity.h b/src/core/entity.h index fea784a..8bf637d 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -189,6 +189,9 @@ public:  		return entity_destroyed;  	} +	/// list inventory, if available, to console +	void list_inventory() const; +  	/* ---- mutators -------------------------------------------------- */  	/// assign entity color @@ -252,10 +255,10 @@ public:  		entity_radius = radius;  	} -	/* ---- actors ---------------------------------------------------- */ +/* ---- actors ---------------------------------------------------- */  	/// called when the entity received a docking request -	virtual void dock(core::Entity *entity); +	virtual void dock(Entity *entity);  	/// set flags  	inline void set_flag(Flags flag) { diff --git a/src/core/item.h b/src/core/item.h index 397d259..f1d6bb5 100644 --- a/src/core/item.h +++ b/src/core/item.h @@ -41,7 +41,7 @@ public:  	  * @brief flags  	  */  	 inline int flags() const { return item_flags; } -	  +	    	/* ---- mutators ----------------------------------------------- */  	/** @@ -49,6 +49,20 @@ public:  	 */  	 void set_amount(const int amount); +	/** +	  * @brief set specified flags +	  */ +	inline void set_flag(Flags flag) { +		item_flags |= flag; +	} + +	/** +	  * @brief unset specified flags +	  */ +	inline void unset_flag(Flags flag) { +		item_flags &= ~flag; +	} +	  private:  	const Info			*item_info;  	int 				item_amount; diff --git a/src/core/parser.cc b/src/core/parser.cc index 7ef44d9..8018bf7 100644 --- a/src/core/parser.cc +++ b/src/core/parser.cc @@ -65,7 +65,7 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)  		entity->info()->add_text(strval);  		return true; -	} else if (inifile.got_key_string("label", strval)) { +	} else if (inifile.got_key_label("label", strval)) {  		entity->set_label(strval);  		return true;  | 
