-ChatPrompt::ChatPrompt(std::wstring prompt, u32 history_limit):
+ChatPrompt::ChatPrompt(const std::wstring &prompt, u32 history_limit):
m_prompt(prompt),
m_line(L""),
m_history(),
// message text
EnrichedString text;
- ChatLine(std::wstring a_name, std::wstring a_text):
+ ChatLine(const std::wstring &a_name, const std::wstring &a_text):
age(0.0),
name(a_name),
text(a_text)
{
}
- ChatLine(EnrichedString a_name, EnrichedString a_text):
+ ChatLine(const EnrichedString &a_name, const EnrichedString &a_text):
age(0.0),
name(a_name),
text(a_text)
class ChatPrompt
{
public:
- ChatPrompt(std::wstring prompt, u32 history_limit);
+ ChatPrompt(const std::wstring &prompt, u32 history_limit);
~ChatPrompt();
// Input character or string
CraftOutput():
item(""), time(0)
{}
- CraftOutput(std::string item_, float time_):
+ CraftOutput(const std::string &item_, float time_):
item(item_), time(time_)
{}
std::string dump() const;
CraftReplacements():
pairs()
{}
- CraftReplacements(std::vector<std::pair<std::string, std::string> > pairs_):
+ CraftReplacements(const std::vector<std::pair<std::string, std::string> > &pairs_):
pairs(pairs_)
{}
std::string dump() const;
CraftDefinitionFuel():
recipe(""), hash_inited(false), burntime()
{}
- CraftDefinitionFuel(std::string recipe_,
+ CraftDefinitionFuel(const std::string &recipe_,
float burntime_,
const CraftReplacements &replacements_):
- recipe(recipe_), hash_inited(false), burntime(burntime_), replacements(replacements_)
+ recipe(recipe_),
+ hash_inited(false),
+ burntime(burntime_),
+ replacements(replacements_)
{}
virtual ~CraftDefinitionFuel(){}
{
MutexAutoLock lock(this->m_time_lock);
if (m_time_of_day > time)
- m_day_count++;
+ ++m_day_count;
m_time_of_day = time;
m_time_of_day_f = (float)time / 24000.0;
}
// Sync at overflow
if (m_time_of_day + units >= 24000) {
sync_f = true;
- m_day_count++;
+ ++m_day_count;
}
m_time_of_day = (m_time_of_day + units) % 24000;
if (sync_f)
class BaseException : public std::exception
{
public:
- BaseException(const std::string &s) throw()
- {
- m_s = s;
- }
+ BaseException(const std::string &s) throw(): m_s(s) {}
~BaseException() throw() {}
virtual const char * what() const throw()
{
class ClientStateError : public BaseException {
public:
- ClientStateError(std::string s): BaseException(s) {}
+ ClientStateError(const std::string &s): BaseException(s) {}
};
class PrngException : public BaseException {
public:
- PrngException(std::string s): BaseException(s) {}
+ PrngException(const std::string &s): BaseException(s) {}
};
class ModError : public BaseException {
struct LocalFormspecHandler : public TextDest
{
- LocalFormspecHandler(std::string formname):
- m_client(0)
+ LocalFormspecHandler(const std::string &formname):
+ m_client(NULL)
{
m_formname = formname;
}
m_formname = formname;
}
- void gotText(const std::wstring &message)
- {
- errorstream << "LocalFormspecHandler::gotText old style message received" << std::endl;
- }
-
void gotText(const StringMap &fields)
{
if (m_formname == "MT_PAUSE_MENU") {
class HTTPFetchOngoing
{
public:
- HTTPFetchOngoing(HTTPFetchRequest request, CurlHandlePool *pool);
+ HTTPFetchOngoing(const HTTPFetchRequest &request, CurlHandlePool *pool);
~HTTPFetchOngoing();
CURLcode start(CURLM *multi);
};
-HTTPFetchOngoing::HTTPFetchOngoing(HTTPFetchRequest request_, CurlHandlePool *pool_):
+HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_,
+ CurlHandlePool *pool_):
pool(pool_),
curl(NULL),
multi(NULL),
}
ItemStack::ItemStack(const std::string &name_, u16 count_,
- u16 wear_, IItemDefManager *itemdef)
+ u16 wear_, IItemDefManager *itemdef) :
+ name(itemdef->getAlias(name_)),
+ count(count_),
+ wear(wear_)
{
- name = itemdef->getAlias(name_);
- count = count_;
- wear = wear_;
-
if (name.empty() || count == 0)
clear();
else if (itemdef->get(name).type == ITEM_TOOL)
Inventory
*/
-InventoryList::InventoryList(std::string name, u32 size, IItemDefManager *itemdef)
+InventoryList::InventoryList(const std::string &name, u32 size, IItemDefManager *itemdef):
+ m_name(name),
+ m_size(size),
+ m_width(0),
+ m_itemdef(itemdef)
{
- m_name = name;
- m_size = size;
- m_width = 0;
- m_itemdef = itemdef;
clearItems();
- //m_dirty = false;
}
InventoryList::~InventoryList()
return taken;
}
-ItemStack InventoryList::peekItem(u32 i, u32 peekcount) const
-{
- if(i >= m_items.size())
- return ItemStack();
-
- return m_items[i].peekItem(peekcount);
-}
-
void InventoryList::moveItemSomewhere(u32 i, InventoryList *dest, u32 count)
{
// Take item from source list
class InventoryList
{
public:
- InventoryList(std::string name, u32 size, IItemDefManager *itemdef);
+ InventoryList(const std::string &name, u32 size, IItemDefManager *itemdef);
~InventoryList();
void clearItems();
void setSize(u32 newsize);
// Returns empty item if couldn't take any.
ItemStack takeItem(u32 i, u32 takecount);
- // Similar to takeItem, but keeps the slot intact.
- ItemStack peekItem(u32 i, u32 peekcount) const;
-
// Move an item to a different list (or a different stack in the same list)
// count is the maximum number of items to move (0 for everything)
// returns number of moved items
private:
std::vector<ItemStack> m_items;
- u32 m_size, m_width;
std::string m_name;
+ u32 m_size, m_width;
IItemDefManager *m_itemdef;
};
};
/******************************************************************************/
-ItemDefinition read_item_definition(lua_State* L,int index,
- ItemDefinition default_def)
+void read_item_definition(lua_State* L, int index,
+ const ItemDefinition &default_def, ItemDefinition &def)
{
- if(index < 0)
+ if (index < 0)
index = lua_gettop(L) + 1 + index;
- // Read the item definition
- ItemDefinition def = default_def;
-
def.type = (ItemType)getenumfield(L, index, "type",
es_ItemType, ITEM_NONE);
getstringfield(L, index, "name", def.name);
// "" = no prediction
getstringfield(L, index, "node_placement_prediction",
def.node_placement_prediction);
-
- return def;
}
/******************************************************************************/
lua_newtable(L);
// For each groupcap
for (ToolGCMap::const_iterator i = toolcap.groupcaps.begin();
- i != toolcap.groupcaps.end(); i++) {
+ i != toolcap.groupcaps.end(); ++i) {
// Create groupcap table
lua_newtable(L);
const std::string &name = i->first;
// Create subtable "times"
lua_newtable(L);
for (UNORDERED_MAP<int, float>::const_iterator
- i = groupcap.times.begin(); i != groupcap.times.end(); i++) {
+ i = groupcap.times.begin(); i != groupcap.times.end(); ++i) {
lua_pushinteger(L, i->first);
lua_pushnumber(L, i->second);
lua_settable(L, -3);
lua_newtable(L);
// For each damage group
for (DamageGroup::const_iterator i = toolcap.damageGroups.begin();
- i != toolcap.damageGroups.end(); i++) {
+ i != toolcap.damageGroups.end(); ++i) {
// Create damage group table
lua_pushinteger(L, i->second);
lua_setfield(L, -2, i->first.c_str());
InventoryList *invlist = inv->addList(name, listsize);
int index = 0;
for(std::vector<ItemStack>::const_iterator
- i = items.begin(); i != items.end(); i++){
+ i = items.begin(); i != items.end(); ++i){
if(forcesize != -1 && index == forcesize)
break;
invlist->changeItem(index, *i);
void push_tool_capabilities (lua_State *L,
const ToolCapabilities &prop);
-ItemDefinition read_item_definition (lua_State *L, int index,
- ItemDefinition default_def);
+void read_item_definition (lua_State *L, int index, const ItemDefinition &default_def,
+ ItemDefinition &def);
void read_object_properties (lua_State *L, int index,
ObjectProperties *prop,
IItemDefManager *idef);
def.node_placement_prediction = "__default";
// Read the item definition
- def = read_item_definition(L, table, def);
+ read_item_definition(L, table, def, def);
// Default to having client-side placement prediction for nodes
// ("" in item definition sets it off)
ToolCapabilities(
float full_punch_interval_=1.4,
int max_drop_level_=1,
- ToolGCMap groupcaps_=ToolGCMap(),
- DamageGroup damageGroups_=DamageGroup()
+ const ToolGCMap &groupcaps_ = ToolGCMap(),
+ const DamageGroup &damageGroups_ = DamageGroup()
):
full_punch_interval(full_punch_interval_),
max_drop_level(max_drop_level_),
u16 wear;
std::string main_group;
- DigParams(bool a_diggable=false, float a_time=0, u16 a_wear=0,
- std::string a_main_group=""):
+ DigParams(bool a_diggable = false, float a_time = 0.0f, u16 a_wear = 0,
+ const std::string &a_main_group = ""):
diggable(a_diggable),
time(a_time),
wear(a_wear),