Guild icon
Teeworlds
IRC / bridge
One-way IRC channel bridge. If you want to be able to send messages to IRC, contact @Dune or @heinrich5991. https://www.teeworlds.com/?page=docs&wiki=rules/irc_rules
Between 2019-06-25 00:00:00Z and 2019-06-26 00:00:00Z
Avatar
hey can anyone tell me what kernel()->RequestInterface does?
Avatar
for many classes, there is only one "global" instance
10:49
this basically allows you to get that instance
Avatar
what if iam hacking something and have multiple instances?
10:49
i see i need a specified name
Avatar
not really supported by this system. what class do you duplicate?
Avatar
perhaps you don't need to register it to the kernel
10:50
src/game/layers.cpp: m_pMap = pMap ? pMap : pKernel->RequestInterface<IMap>(); src/game/server/gamecontext.cpp: CTile *pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data); src/engine/server/server.cpp: m_pMap = Kernel()->RequestInterface<IEngineMap>(); src/engine/client/client.cpp: m_pMap = Kernel()->RequestInterface<IEngineMap>(); src/game/client/components/mapimages.cpp: LoadMapImages(Kernel()->RequestInterface<IMap>(), Layers(), MAP_TYPE_GAME);
10:50
eh
10:51
see my problem?
10:51
what happens if i call Kernel()->RequestInterface<IEngineMap>() multiple times?
Avatar
you get the same instance every time
Avatar
this breaks everything 😄
Avatar
you need a different system if you want to have more than one map
Avatar
perhaps pass it via parameters instead of the interfaces requesting it from the kernel
Avatar
after loading dm1 my server crashes (while having loaded another map)
Avatar
what do you want to achieve?
Avatar
yes, I will do this
Avatar
loading multiple maps?
Avatar
multimap, like Kosmo archived
10:53
should I show you?
Avatar
yea, then do it like described above 🙂
Avatar
nah, I think I saw it already
Avatar
this new technique has so much potential
10:55
you could autogenerate maps on the fly
Avatar
yup 🙂
Avatar
the class CMap is declared in a cpp file (engine/shared/map.cpp), but why? Shouldn't it have a header
Avatar
the header (src/engine/map.h) contains the "interface", i.e. all the members of the map that are exposed on purpose
11:07
this way you can do whatever you like in the class CMap without accidentally enlarging the interface
Avatar
I have never seen a class declaration in a cpp, but okay, this makes sense
Avatar
src/engine/client/text.cpp:class CTextRender : public IEngineTextRender src/engine/shared/kernel.cpp:class CKernel : public IKernel src/engine/shared/masterserver.cpp:class CMasterServer : public IEngineMasterServer src/engine/shared/storage.cpp:class CStorage : public IStorage src/engine/shared/config.cpp:class CConfig : public IConfig src/engine/shared/map.cpp:class CMap : public IEngineMap src/engine/shared/engine.cpp:class CEngine : public IEngine
11:09
these are the instances in teeworlds
11:09
this pattern is also used at the game/engine boundary
11:09
you'll see a few interfaces (e.g. for the gameclient/gameserver and engine client/engine server) in src/engine/*.h
Avatar
I normally use singletons if i want this behaviour
Avatar
I don't see how this is related to singletons — this tries to achieve that there is one clear interface which is used for communication (edited)
Avatar
now it makes sense to me
11:11
a singleton provieds one global instance, too
11:11
but not the clear single interface aspect
Avatar
ah
Avatar
I don't see the difference with sigletons
Avatar
as far as I understand it, "singleton" means that there exists exactly one instance of that class
Avatar
Recently I've bumped into a realization/implementation of the Singleton design pattern for C++. It has looked like this (I have adopted it from the real life example): // a lot of methods are omit...
Avatar
the pattern used in teeworlds code means that there is a separation between interface (the IMap class) and the implementation (the CMap class)
11:19
hum, fun. IRC displays my "the pattern used in teeworlds code" below @Assa's stackoverflow link. apparently discord doesn't synchronize order
Avatar
isn't that the right order? It shows me the same
Avatar
it doesn't show the same for me in discord
Avatar
Discord probably has another consistency model
Avatar
Do i have to include the kernel for using its interfaces?
Avatar
almost all files already include <kernel.h>, so realistically: no
Avatar
because i get a runtime crash when calling Kernel()->RequestInterface<IStorage>()
Avatar
have you checked why?
Avatar
invalid write of size 8 says valgrind
Avatar
huh write.
Avatar
you can put it into gdb to get the exact function where it's crashing
Avatar
my mistake
11:36
Segmentation fault, IStorage ist ein nullpointer oO
Avatar
not Kernel()?
Avatar
doch Kernel ...
Avatar
you have to use RegisterInterface on your class or stop inheriting from IInterface
Avatar
Nice, this helped a lot ❤
11:50
thank you
Avatar
ChillerDragon 2019-06-25 12:13:43Z
isnt autogen maps on the fly opensoruce already?
12:15
there was this BuggyCrapGores repo once somewhere
Avatar
@heinrich5991 I did it ^.^ I just spawned in the wall outside of dm1 but thats not my business yet 😄
Avatar
cool 🙂 (edited)
Avatar
Ninslash (the game by siile based on teeworlds) has automaping, and its open source
Avatar
i will take a look at it, thank you ^^
Avatar
hey Heinrich, what would happen if i use the same storage for all maps?
16:09
can you explain what the storage does?
Avatar
@heinrich5991 discord reorders messages a posteriori iirc
Avatar
@Assa sharing storage is no problem
18:56
storage just handles the logic that teeworlds looks in the data directory next to teeworlds.exe and also in the user profile in %APPDATA%
Avatar
@Dune doesn't seem like it, @Assa and I had different message orders in discord
Exported 80 message(s)