Minetest logo

IRC log for #minetest-dev, 2019-05-05

| Channels | #minetest-dev index | Today | | Google Search | Plaintext

All times shown according to UTC.

Time Nick Message
00:04 Taoki joined #minetest-dev
00:28 Fritigern joined #minetest-dev
00:47 paramat joined #minetest-dev
01:11 Sokomine joined #minetest-dev
01:30 Cornelia joined #minetest-dev
02:26 Miner_48er joined #minetest-dev
04:09 paramat joined #minetest-dev
04:53 reductum joined #minetest-dev
07:15 paramat joined #minetest-dev
08:28 pyrollo joined #minetest-dev
08:42 ANAND Hi. Is there a way to compare to ItemStacks in C++?
08:42 ensonic joined #minetest-dev
08:42 ANAND I could do stack1.serialize() == stack2.serialize(), but I was wondering if there's a more straightforward way to do this.
08:46 nerzhul you must implemented == operator
08:51 Fixer joined #minetest-dev
08:51 ANAND Will do
08:51 ANAND What properties should it compare?
08:52 ANAND I can think of name, count, and meta
08:52 ANAND Anything else?
08:53 ANAND Oh yeah, wear
08:55 ANAND Why is ItemStack a struct instead of a class, btw?
09:17 pyrollo joined #minetest-dev
10:02 nerzhul attribtes are public ?
10:18 ANAND Yes, but why?
10:54 fwhcat joined #minetest-dev
11:02 nerzhul historical and not refactored if needed ?
11:04 sfan5 ANAND: https://github.com/minetest/minetest/blob/master/src/inventory.cpp#L515-L516
11:04 sfan5 this is what it should compare
11:05 Wuzzy joined #minetest-dev
13:19 fwhcat joined #minetest-dev
13:39 ANAND sfan5: Thanks
13:39 ANAND It compares meta directly?
13:40 ANAND I thought only the serialized versions can be compared
13:44 rubenwardy that really should be in an operator==
13:45 rubenwardy an operator== will be inlined anyway
13:54 Fritigern joined #minetest-dev
13:57 ANAND rubenwardy: That's what I'm in the process of implementing
14:03 ANAND Wha... operators == and != have been defined for comparing ItemStacks in around 15 files
14:05 rubenwardy lool
14:13 ANAND And multiple definitions warnings pop up for each file that defines the operator, since the header has declared it's own version now
14:13 ANAND https://gist.github.com/ClobberXD/b87cd0b41baa4220747f699c1cb00939
14:13 ANAND 15 is an understatement
14:13 ANAND That's probably around 30
14:13 rubenwardy I think you've defined it wrong
14:13 rubenwardy those files all include the ItemStack file
14:14 ANAND exactly, but they've also declared and defined their own versions of the operators
14:14 sfan5 no
14:14 sfan5 you forgot to make the method inline
14:14 rubenwardy or as part of the class
14:14 rubenwardy if you don't define a method as inline, extern, or static in a header then you will get multiple redefinitions
14:15 rubenwardy *global method
14:15 rubenwardy in this case, I'd suggest moving into the class like
14:15 ANAND Wait... The errors are only for != operator, which I've defined in the header itself, using !(s1 == s2)
14:15 rubenwardy bool operator==(const ItemStack &other) const {
14:15 rubenwardy basically, #include is a copy and paste of another file
14:15 ANAND Alright
14:15 ANAND Yea
14:16 rubenwardy to the compile, it's as if you have that code directly in the C++ file
14:16 rubenwardy and so each cpp file has a definition of that operator
14:16 ANAND :facepalm:
14:17 ANAND Should it be defined inline or in the .cpp file if it's a member of the class?
14:18 rubenwardy as a member of the class
14:18 rubenwardy bool operator==(const ItemStack &other) const {
14:18 ANAND Yes, but in .h within class decl. or in the .cpp file?
14:18 rubenwardy .h
14:19 ANAND Okie
14:19 rubenwardy the .h, because the definition is trivial and it allows inlining
14:22 ANAND Understood, thanks :)
15:46 fwhcat joined #minetest-dev
16:10 calcul0n_ joined #minetest-dev
16:31 Lia joined #minetest-dev
18:09 Cornelia joined #minetest-dev
18:32 fwhcat joined #minetest-dev
18:52 proller joined #minetest-dev
19:04 reductum joined #minetest-dev
19:39 Owner_ joined #minetest-dev
19:54 fwhcat_ joined #minetest-dev
20:14 fwhcat_ joined #minetest-dev
20:28 Ruslan1 joined #minetest-dev
20:29 Owner__ joined #minetest-dev
20:47 proller joined #minetest-dev
20:54 pyrollo joined #minetest-dev
20:57 paramat joined #minetest-dev
21:42 Miner_48er joined #minetest-dev
23:48 calcul0n_ joined #minetest-dev

| Channels | #minetest-dev index | Today | | Google Search | Plaintext