Categories
Dirty-Commits

DC: TeamSpeak 3 & Icons

Introducing “Dirty-Commits”

Welcome to “Dirty-Commits”.
The format/category where I talk about non-fancy (or even ugly) work-arounds I had to commit into my git history in order to get things working.

Background

The TeamSpeak 3 Server Query API provides a command to retrieve information on the channels of the server (channellist). Using the -icon flag includes the channel_icon_id property.
That icon ID is a CRC32 checksum which is used to identify the icon.

The problem

Earlier this year, I experimented with a plugin that would enforce channel icons for certain channels so they would not be changed even by permitted users.
I quickly noticed that the plugin went totally haywire, editing every watched channel in each check cycle.

At first, I thought that I had mistakenly messed up the check for the icon ID but that turned out to be false pretty quickly. Upon checking the messages returned by the server I discovered that the channel icon ID sent by the server looked weird in that it was negative.

Let’s take a look at the example I was examining:
The icon in question has the ID 3948173233 and setting the channel property to that ID did result in the correct icon being set.
But, for some reason, when returning the channel list, TeamSpeak always returns -346794063 which obviously is not correct.

I went into hours of googling for any hints of other people encountering that issue but it seemed that this issue was unique to our setup. At some point I realized that setups using MariaDB as the database do not seem to be that common. So I tried reproducing this issue with no database server configured.
And it went away? So something must be wrong with the data transition from the database to the query connection. Having previously checked that the data lands in the tables correctly that seemed like the only place where the issue could be caused.

Just having recently had to attend a technical fundamentals of computer science course I had the 2-complement swirling around in my head.
I thought myself: “Why not use this as an exercise for converting numbers between decimals and binary” although I was not really sure what to expect at that moment.

This however, showed me how to work around the issue:
-346794063 in 2-complementary representation is 111010110101010001010111101 which in turn is 3948173233 when interpreted as an unsigned integer.
But wait! That is the real icon ID!

So yeah. It appears that TeamSpeak messes up the integer representation when constructing the query message and reads the unsigned integer as a signed one.

The “solution”

Commit ff5a7631 in the server bot framework will make sure this issue will never be passed to any plugins of the framework.
Whenever a negative icon ID is passed to the framework, it will be re-interpreted as an unsigned integer, resulting in the correct ID being stored.

Categories
Introducing

Introducing: Me

Of course, one of the first posts of a blog must be an introduction of the author. So, this is me:

My name is Magnus Leßmann and I’m also known as “MarkL4YG” (and thus also just “Mark”) on the Internet.
I currently wield about 20 years of experience in “Life” and started developing interest in Software back in 2011 when a friend of mine and I started playing the one and only now well known Minecraft.

Apart from setting up the server, I also started coding in Lua via. Computer Craft to program more and more complex factories. (Theres also a brief foreplay with Delphi 1 during a course I attended where I met that friend but there’s nothing of any importance to write about.)

Since then, I have always been part of a gaming community as a developer and administrator.
At the moment of writing, that is FearNixx Gaming of which I am the lead developer, system administrator and a co-founder.

Up until now I have learned to use Pascal, Lua, Java, Shell, JavaScript, PHP, SCSS, some C#, aswell as some C++ for my Arduino board.
I have briefly touched many other languages but would not yet count any of them to this list.

I will not go into detail about my current and former projects as I am planning to dedicate a custom page to them.

I am currently studying applied computer sciences at the NORDAKADEMIE in Germany which accounts for the most of my time spent.
And sporadically showing up at the CCCHH, as well as voluntary firefighting also form occupations on my time table.

I am always excited to learn new features, languages, frameworks but especially people regardless of their hobbies as I feel like different opinions can enrich the overall view of things.
So, if you feel inclined to say “Hello”, don’t hesitate to contact me using any of the methods listed on the contact page.

Have a nice time!
Magnus

Categories
home Introducing

Introducing: My blog

Ever since I started programming web sites and components, I regularly stumble upon a particular opinion that – although pretty much compatible with my own thoughts – did never really hit open ears on my side.

Every developer should have an own blog to share their experiences to.

So here we are. I now have finally taken time to set up my own blog using WordPress. (Huge thanks you to WordPress and the ResponsiveBlogily theme for being free by the way!)

I’ll probably be posting previous experiences during the winter months as I can already think of some that might help during a Google search.

So yeah, have fun reading!