aboutsummaryrefslogtreecommitdiff
path: root/src/unittest
Commit message (Expand)AuthorAge
* Fix find_nodes_in_area misbehaving with out-of-map coordinates (#11770)sfan52021-11-26
* Localize error messages in mainmenu (#11495)Riceball LEE2021-11-01
* Add "MINETEST_MOD_PATH" environment variable (#11515)emixa-d2021-10-07
* Shave off buffer copies in networking code (#11607)sfan52021-09-17
* Hide Wself-assign-overloaded and Wself-move unittest compilation warningsHybridDog2021-09-17
* Make sure relevant std::stringstreams are set to binarysfan52021-09-11
* Switch MapBlock compression to zstd (#10788)lhofhansl2021-08-31
* Rework Settings to support arbitrary hierarchies (#11352)sfan52021-06-23
* Fix base64 validation and add unittests (#10515)Lars Müller2021-05-30
* fix: some code tidy about includes & irr namespacesLoic Blot2021-05-03
* refacto: don't use RenderingEngine singleton on CAOLoic Blot2021-05-03
* Schematic: Properly deal with before/after node resolving and document (#11011)SmallJoker2021-03-20
* Encode high codepoints as surrogates to safely transport wchar_t over networksfan52021-02-02
* Drop wide/narrow conversion functionssfan52021-02-02
* Refactor utf8_to_wide/wide_to_utf8 functionssfan52021-02-02
* Rework use_texture_alpha to provide three opaque/clip/blend modessfan52021-01-29
* Settings: Purge getDefault, clean FontEngineSmallJoker2021-01-29
* Settings: Proper priority hierarchySmallJoker2021-01-29
* Remove unused functions reported by cppcheck (#10463)SmallJoker2020-10-05
* (se)SerializeString: Include max length in the nameSmallJoker2020-10-01
* Clean up serializationSmallJoker2020-10-01
* Settings: Fix unittest memory leak, change input typesSmallJoker2020-09-22
* Remove Thread::kill() and related unittest (#10317)Sebastien Marie2020-09-10
* Load media from subfolders (#9065)DS2020-08-20
* TestBan: Clean up properly after completing test (#9994)ANAND2020-06-05
* Rename “Minimal development test” to “Development Test” (#9928)Wuzzy2020-05-26
* Allow ObjDefManager instances to be clonedsfan52020-05-05
* Optimize get_objects_inside_radius calls (#9671)Loïc Blot2020-04-16
* Drop content_sao.{cpp,h}Loic Blot2020-04-11
* Collision various fixes (#9343)TheTermos2020-04-08
* Add limit parameter to decompressZlibBen Deutsch2020-02-01
* Settings: Add get_flags API for mapgen flags (mg_flags, mgv6_spflags, ...) (#...SmallJoker2020-01-25
* StaticText/EnrichedString: Styling support (#9187)SmallJoker2020-01-22
* Fix AreaStore's IDs persistence (#8888)SmallJoker2019-09-21
* Inventory: Send dirty lists where appropriate (#8742)SmallJoker2019-08-24
* Fix compare between pointer and 0 in unittestsJozef Behran2019-08-13
* Optimize string (mis)handling (#8128)Jozef Behran2019-05-18
* Add Irrlicht-specific smart pointer (#6814)Vitaliy2019-04-12
* LINT fixLoïc Blot2019-02-15
* Fix Address::isLocalhost algorithmLoic Blot2019-02-09
* Use true pitch/yaw/roll rotations without loss of precision by pgimeno (#8019)Paul Ouellette2019-02-07
* Proselytize the network. Use IEEE F32 (#8030)SmallJoker2019-01-03
* Fix the part of the float test that requires IEC559/IEEE754 compliancePedro Gimeno2018-12-18
* Add an activeobject manager to hold active objects (#7939)Loïc Blot2018-12-13
* Network: Send IEEE floats (#7768)SmallJoker2018-12-13
* Add testWrapDegrees_0_360_v3f unittestsLoïc Blot2018-12-04
* Move client-specific files to 'src/client' (#7902)Quentin Bazin2018-11-28
* Fix temporary path crash in TestAuthDatabase (#7753)SmallJoker2018-09-28
* Replace auth.txt with SQLite auth database (#7279)Ben Deutsch2018-08-05
* Add a MSVC / Windows compatible snprintf function (#7353)nOOb31672018-07-22
pt">= 0; metadata = ""; } void add(u16 n) { count += n; } void remove(u16 n) { assert(count >= n); count -= n; if(count == 0) clear(); // reset name, wear and metadata too } // Maximum size of a stack u16 getStackMax(IItemDefManager *itemdef) const { s16 max = itemdef->get(name).stack_max; return (max >= 0) ? max : 0; } // Number of items that can be added to this stack u16 freeSpace(IItemDefManager *itemdef) const { u16 max = getStackMax(itemdef); if(count > max) return 0; return max - count; } // Returns false if item is not known and cannot be used bool isKnown(IItemDefManager *itemdef) const { return itemdef->isKnown(name); } // Returns a pointer to the item definition struct, // or a fallback one (name="unknown") if the item is unknown. const ItemDefinition& getDefinition( IItemDefManager *itemdef) const { return itemdef->get(name); } // Get tool digging properties, or those of the hand if not a tool const ToolCapabilities& getToolCapabilities( IItemDefManager *itemdef) const { ToolCapabilities *cap; cap = itemdef->get(name).tool_capabilities; if(cap == NULL) cap = itemdef->get("").tool_capabilities; assert(cap != NULL); return *cap; } // Wear out (only tools) // Returns true if the item is (was) a tool bool addWear(s32 amount, IItemDefManager *itemdef) { if(getDefinition(itemdef).type == ITEM_TOOL) { if(amount > 65535 - wear) clear(); else if(amount < -wear) wear = 0; else wear += amount; return true; } else { return false; } } // If possible, adds newitem to this item. // If cannot be added at all, returns the item back. // If can be added partly, decremented item is returned back. // If can be added fully, empty item is returned. ItemStack addItem(const ItemStack &newitem, IItemDefManager *itemdef); // Checks whether newitem could be added. // If restitem is non-NULL, it receives the part of newitem that // would be left over after adding. bool itemFits(const ItemStack &newitem, ItemStack *restitem, // may be NULL IItemDefManager *itemdef) const; // Takes some items. // If there are not enough, takes as many as it can. // Returns empty item if couldn't take any. ItemStack takeItem(u32 takecount); // Similar to takeItem, but keeps this ItemStack intact. ItemStack peekItem(u32 peekcount) const; /* Properties */ std::string name; u16 count; u16 wear; std::string metadata; }; class InventoryList { public: InventoryList(std::string name, u32 size, IItemDefManager *itemdef); ~InventoryList(); void clearItems(); void setSize(u32 newsize); void setWidth(u32 newWidth); void setName(const std::string &name); void serialize(std::ostream &os) const; void deSerialize(std::istream &is); InventoryList(const InventoryList &other); InventoryList & operator = (const InventoryList &other); const std::string &getName() const; u32 getSize() const; u32 getWidth() const; // Count used slots u32 getUsedSlots() const; u32 getFreeSlots() const; // Get reference to item const ItemStack& getItem(u32 i) const; ItemStack& getItem(u32 i); // Returns old item. Parameter can be an empty item. ItemStack changeItem(u32 i, const ItemStack &newitem); // Delete item void deleteItem(u32 i); // Adds an item to a suitable place. Returns leftover item (possibly empty). ItemStack addItem(const ItemStack &newitem); // If possible, adds item to given slot. // If cannot be added at all, returns the item back. // If can be added partly, decremented item is returned back. // If can be added fully, empty item is returned. ItemStack addItem(u32 i, const ItemStack &newitem); // Checks whether the item could be added to the given slot // If restitem is non-NULL, it receives the part of newitem that // would be left over after adding. bool itemFits(const u32 i, const ItemStack &newitem, ItemStack *restitem = NULL) const; // Checks whether there is room for a given item bool roomForItem(const ItemStack &item) const; // Checks whether the given count of the given item name // exists in this inventory list. bool containsItem(const ItemStack &item) const; // Removes the given count of the given item name from // this inventory list. Walks the list in reverse order. // If not as many items exist as requested, removes as // many as possible. // Returns the items that were actually removed. ItemStack removeItem(const ItemStack &item); // Takes some items from a slot. // If there are not enough, takes as many as it can. // 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) void moveItem(u32 i, InventoryList *dest, u32 dest_i, u32 count = 0); private: std::vector<ItemStack> m_items; u32 m_size, m_width; std::string m_name; IItemDefManager *m_itemdef; }; class Inventory { public: ~Inventory(); void clear(); void clearContents(); Inventory(IItemDefManager *itemdef); Inventory(const Inventory &other); Inventory & operator = (const Inventory &other); void serialize(std::ostream &os) const; void deSerialize(std::istream &is); InventoryList * addList(const std::string &name, u32 size); InventoryList * getList(const std::string &name); const InventoryList * getList(const std::string &name) const; std::vector<const InventoryList*> getLists(); bool deleteList(const std::string &name); // A shorthand for adding items. Returns leftover item (possibly empty). ItemStack addItem(const std::string &listname, const ItemStack &newitem) { InventoryList *list = getList(listname); if(list == NULL) return newitem; return list->addItem(newitem); } private: // -1 if not found const s32 getListIndex(const std::string &name) const; std::vector<InventoryList*> m_lists; IItemDefManager *m_itemdef; }; #endif