A Tale of Two Code Changes



April 12th, 2021 by Diana Coman

This past week I worked on a significant refinement of Eulora's data hierarchy, that core structure used to fully describe for the client the game's endless, complex and ever-changing world. As it happens, this refinement was made possible as a result of a lot of previous work1: having recently gained full control over the creation of all graphical elements as I successfully grew my own mountains alongside GUI elements and literally everything else involved, I was also finally able to break up into more useful pieces and ultimately get rid of that sore anomaly of an "Outdoors" object that had previously catered to the requirements of the now-discarded "terrain plugin".

For the easy part in getting rid of that bulky and spurious "outdoors" object, I had at least already in place the natural building blocks that would get used, namely the CSModel object as well as the ways to position and even name it, if desired. Even so, a change such as this, touching as it does the game's own way of structuring knowledge essentially, can never be a very easy thing to get right, as there are many different connected pieces that have to fit - at least to some working extent - at all times. So I was a bit apprehensive about the amount of work it might end up requiring in practice and I made therefore a padded estimate of the time it might all take.

At first, I made the needed changes on serverside, where everything is defined and created in the first place anyway. There was initially more work than expected, indeed, but mainly as a side effect, a sort of slightly hurried growth, rather than anything else: while the change to the hierarchy itself was quite straightforward, the details pushed into being other parts that weren't yet quite ready otherwise, although they were somewhere further down on the list for later, anyways. So I took more time than I had initially estimated to design and then add the needed embryos of these parts too, even though they still miss a lot of other parts that they in turn require and as such, they are sure to further change as they develop. This is expected and unavoidable though - it's how everything else on serverside currently came into being as well, after all.

As the serverside work stretched even beyond my padded estimate for it, I was increasingly thinking that I'll have no choice but to revise the overall estimate entirely, as the remaining time for the whole clientside work shrank and shrank. But then, when I finally got to update the data hierarchy in my own EuCore component on clientside, there was indeed very little required: simply the addition of the new object types, the deletion of the old one and a few updates (flagged automatically, too!) to take them as well into consideration when looking for broader categories such as "graphics vs non-graphics objects". The rest of it - and moreover, the *more significant* and difficult rest of it simply worked and not by accident either: it was simply my previous design and implementation of both EuCore and its interfacing with the GUI saving me days of work now, as it handled entirely new types without skipping a beat and without requiring otherwise any change *at all*. How pleasant is this as code to work with and when exactly is the last time you encountered such ease when making significant changes to the code you are working on?

The second code change that made its way onto my list this past week was in principle a very simple thing to do, clientside entirely: as the water was now simply a CSModel like any other item in the world, it ended up nicely rendered but nevertheless surprisingly...solid, despite the data hierarchy otherwise holding enough information as to its "water" nature. In other words, there was clearly a need for the GUI part of the client itself to become a bit more discerning and create water as water (not solid and also reflecting things around, for instance). Since I had already written the code that successfully created water as such, this change was in principle just a matter of adding and using a flag, nothing more.

In practice though - in hindsight unsurprisingly, as it touched the remaining PS code - the simple change turned out to be not that simple and especially not as straightforward as expected: first, the water was rendered reflecting quite nicely everything around, so that it was clear that the discerning part worked as expected but... this "water" was still a solid, more like frozen ice perhaps than any water. Then it all got even more puzzling: the water was still solid *despite* my loader specifically *not* setting collision detection on it (in graphics terms, this solidity is simply a matter of whether one bothers to check /enforce any bumping into the object in question or not). Moreover, this unexpected solid was not even reliably solid but rather a weird half-assed sort of solid: one would walk on water indeed, for all the incredulity one might have as to the possibility of such feats but then, unexpectedly (a loss of faith, perhaps - whose faith, though?), one would sink deep into it and then... oh, then, one would get *stuck* in there, too, unable to move in any direction, if able nevertheless to spin as much as desired! Basically I had inadvertently created in there a sort of treacherous quicksands for all their watery looks otherwise.

Both the cause of and the resolution to the above unexpected wtf turned out to be of the same sort as previously encountered: the cause was a remaining bit of planeshift code and the resolution was to discard it entirely. Basically there was a spurious "psSolid" wrapping of the engine's own collision detection object doing nothing other than getting in the way - it literally added *nothing* of its own other than the perpetrator's name at the top of the file2 and otherwise another indirection layer in the way of anyone trying to make sense of the code overall. On top of this, some other bit of remaining PS code *also* took it upon itself to decide and add this half-assed psSolid thing to *everything* that went through it, just like that. As a result, there was this funny situation where simply bypassing it all solved the problem entirely - as usual, not playing along with the stupid has this magical effect of making all sorts of problems just... disappear. So I further deleted some of the increasingly less but sadly still remaining PS code and as a reward for it, I had my water being water again, nicely yielding rather than solid and otherwise letting one freely move through it at all times, instead of randomly trapping unaware swimmers in it.

Having previously trimmed and trimmed again at these same planeshift tendrils, this latest trim was otherwise quite effortless too, basically a very pleasant and rewarding way of improving the code from all points of view. How is this for coding work - effortless code *reduction* for added benefits and increased functionality, too. How does this compare with your current coding work and experience as to what coding even involves, hm?


  1. This most recent work merely added, in turn, on top of full years of cleaning up all sorts of strata upon strata of a huge mess

  2. And I have to say that by now I had even guessed correctly the exact "author" name in that file, despite there being quite a few names scattered otherwise around the CS and PS codebase, you know? 

Comments feed: RSS 2.0

7 Responses to “A Tale of Two Code Changes”

  1. -----BEGIN PGP MESSAGE-----
    Version: GnuPG v1

    hQEMA0hiZsbZKp+MAQf/QBa8iRPQoLMC4MgfMiBVo6d0jU04/8uBVZsHO16v9tin
    LE/KmYd0bIv8cMF6QW+iz9vlBUvDPPrsOxP+roAmd/7lX2qPSZ+aBGuCC33/5TwB
    /fypAv1KtLzlCYkDPvb/5HUTz+NaRyjreEvpHhPMoO/44n8PygP6ZTJR4kZdMSqa
    GaiZXoFtiTyMvarUflS8M8UgRhnvtSWq1JSyFcb7ONxXvShIINnsMHOQoW3pFf7y
    F4BECHBFI/kjc/Jnjb8dSChlr5IDp83syE61LuZiMUhnSLE/h+XSFM6rYiLVDKJz
    cL24ZNh4Tgo9nbULJraVfpl9BLE9nhJnDkqxtIrbAtLrAYQQbnu+kEXcaPZTNcZo
    Q0ShzYPB/lrUKIEQ+OkgPt78T7G7szQj0Vgk7Y+WBqheXwfpcU1S/pbfGVHBpcXn
    XSxzDuEwNHdTNUfMGjczmKSRD9TkZ8yj8he14grxzVlOUsNaflYND8WmYAfirhdz
    GkEb2xoiLc724SrGJzVi8mGNG0iUm8GiszBCF9bzmCAJp21MsHnpvk4a9yzooP+S
    mlRqIUL/mCK8PDJ9zb4QKFWD+K6dTwjQ1Fut8AbOkdGNoibNBMeQ3XtKII8QhJxQ
    aMkvbxCO6kK7bxKU9KxNHRnujXiSMSZWv19KJW6UHrq9+9cif+1o2k/am7psmlcG
    gMl5owLoOkvfLQnloPhbokypJFjB+kSuHqtBEcT7ssUjSpMo7VCcace/6q438jb0
    irKeANYW7aGtBkmvV8da1te6IkN9JvA0QKb+G6D7uQW+r/buB55EjkV6w/SZY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0zkqVto
    D7yK+FZTCwSToHCBOWweXmSzyej2uLTd9s1e1yk2YLwI7cmVNgLkpWNUvju/KI21
    alTLJPUUFdtwtPUcVvNdJCb96h5HIO6MobpVpqa8mcOD6iQJEIPghrIjXjv0TAHN
    2motY0wyVl0x2MXKeK/2X/O54C5JMKxaxJrBxxGLr+TCJhXKl6Y0G7LEagNRcpmO
    bCwNNBvZYkHdwxgJGUcqK6vpXlK70PcLOI37mEuPzLiOz3uJRru7PMl+yEdMYK7L
    LiTKmCZQIFC51INNlF/WNc+/JN83d85fCqcGLrGw2pjzgMGfx2RPvIYm7udhEwcd
    6Ban1kry5FY/WlV4LcmpYGUehx1HvaAXEmgjD3Lgvambxd5N8djTLTmXtK9ZnWk+
    4D74ksP99mfQ9fmkq7j28sFRIzb0FS/w2keaRQnVkx7iD9axSMk8Abo+H6jn7gro
    sLlZhRumS2yl18hxXf3Gojoa6/+LTKFDrg9wC1yoGskxRHRs8oT4+O14iXSD7ww0
    3L5ku+dysu9dT/0Kbc7zKoVfcowxHwkjvgU5NPnvdANNQNPeY2+KVN//JBc3u24U
    qqoYKggKN+JiPdnZzO4qP3UHxTZjJ2eB5cMItAzW5Vrnml8bvbuYlYEhSLcrDHHv
    6KI9kbUGiUmtwrt8MPYjubWgtt5Q5AqAO5pK5+GUW6daod73ai9qgT7p243dYgGL
    4nxLkxSMRbWUM8ZzIwcyi7wmflYGvE18Jzwu4mtY+yRId7v1xUGAo7hv48qam/rz
    hgKp89rnccCyvLv9HqGBHU6Dr3QQfbHRyYrL2cEJzj0ZtyhQaZih1ZxUJBdrLS7x
    AQ9hj8KX3M/wD3Bm4yHqTFMEwqI84IEeCMe4Ldb16NiSMDRn2ke0auo3V385HoLC
    PEA6GiOy0SSgmlfEkcNicK3Q0K307TVtqsRWrzW8TfsGHPdU0qM+rhwR0vF9sZDo
    TEEN7i8BS8nVe2LOHRXgU/iop6kiAMvvVa0T+NhzU4MEaK/3haXhdfz395tQYXuj
    dO2jJwQgoJZ1vXYTky2LUiYuO04UszQoH0nOFdXYGxwqSc/PgYV4tVM8ExgXVFoY
    sWXT1IK3SYH+tqWhYqTaUqu3kLs8h689dvsNwuWHTxRPI32zFKyYhgy+7KWXaGl8
    c0PV03GxtgML9Gbb9HPzev1vTCRA3X4+al1R83hTIqzZprhGOmEvW7/RV4xzBJWG
    RuzwLaNSrTuhHxLfbZhCoAMRL8Gfc9wbHEwbNpU7SOuaZfc=
    =LT+B
    -----END PGP MESSAGE-----
  2. > How pleasant is this as code to work with and when exactly is the last time you encountered such ease when making significant changes to the code you are working on?

    Supposedly that's how lisps work ; in my own experience the last time they actually worked that way they were working on 90s irons, items made out of processors and memory banks capable of dealing with entirely inconsequential datasets. That's the kind of sore detail afficionados studiously eschew the faintest mention ; but for my own interest it is paramount, because really now, I can't seem to manage giving the first shit about how excellently the garbage collector worked "back in the day", on sixty megabytes of ram and so on.

  3. -----BEGIN PGP MESSAGE-----
    Version: GnuPG v1

    hQEMA0hiZsbZKp+MAQf+Ij4SxS+p377b3Lzz0/Jzl8xY9etx/U8z3VJ7icYjIdl7
    tJtkM8QibMSVDNUIM4QBbQoI4c7JWe9PMCyBS0g5XeaWMI/TvYyujHEc1F/cP2Jm
    wpmUhejc5lCsfdWu/H0tTrOoE/uHWEZTEFMFFyqAa4g3s0Im8Tf1EfotR9leXWOS
    Wn6B354zMOUqolboIKJrxOA2Fratx4gGQWu6t5hvilu7uHaIxnq0deGGoHkRvYl+
    ldKp3sSyChX6Zdese+MfeETpIgZdZqMrmavgH4SiefNWG18BYQoo2RYzSl/fpja3
    mPTIsFu35XURHVlqgGnF4E7S7f432OFDHRdiDDMIVdLpAY7faLQLpTBXhEuR+j2Y
    2aBeRMkbD7eiOIwtsuB0RWmJvcypUnupnJOmwfVMS7cVlk35cg/Qy9YN/1fnCYLN
    Bol2nRzGvO45NgmgQ7ITG0zv4NVwpZt8v/L2dWL0n8AWxWxRlhb+7x6KdJi0sUU3
    i7jxRyz9iU0DPmpLI/G66eZhsS+VNJBNGPZWZdFobnYe+DI5iZT4aBc88kl+ujAK
    eSs2Bvca8L0wHifGQheLTs0VJ8dBOoZfa6RKZBe1OXPfs9quAsuv0/91RdPRNxoW
    HFzoPw0pjG74RVK79lDaOKq1Y4uUvW75eb96/1o7jeF6Tl1EC7VH6y1oYlF/jk0P
    5aAVPp8zSQZDszOrF9ZCDHiPMVD34fPe0ZVfv0aF1/PxjKQFMdBp84+NARYk2TO1
    sRbZSDcu1joEkh697H8y6DSrFlFr8oW2udobXisS/5eqjeRE7Qij3xg/S2LuBhFu
    oXfy3TeImBY9aJTBeJff2wA9VpIXGDysDnFMxJ6iwkaWEf1s5W/I62p8St49DQar
    z6EfwNcVeyUEb4sU1uIMvS4qCs3erbTf3e31rOx26LBB8wYarl+USTEsB78mBN3u
    eMKNuvv8mA6nZPQtp+6hd5XpuCOjOcY+Dgi2whu1pfq0ayaOZCgoDbJE/oj4oSjP
    YS4JpLa7pymj2crgT22uOOJvLsIV1WjVcwvZR1LdqXbEP2Y5hDpj8TdrrDuWzf8h
    QXtV1b8FrogVXYQXe96M2mnA/Ox5xCYdnMy+AHQWwPTZ7xuxsNtUAbK8wj2DSqpR
    iyOYUEwyBl0//ufDoyGmTjsT3m6kkRyWX/YjB7Hb3Wq2
    =5/Ge
    -----END PGP MESSAGE-----
  4. Diana Coman says:

    In my experience, functional programming (of which Lisp is the most vocal exponent but I'm not so sure it's also necessarily the best one) is very pleasant indeed simply because it allows very elegant modelling of the problem/solution, basically it's as close to pure Maths as "programming" ever got.

    The caveat (similar I suppose to what you mention regarding the "works perfectly" - as long as the environment is inconsequential one way or another) is that functional programming is extremely pleasant indeed only when *it suits* the task at hand - while I did program out of sheer stubbornness (back at uni when I had just discovered functional programming and I was in love with the neatness of it) even some board games in Haskell, Caml and even Scheme, I am not all that sure that it all scales terribly well beyond some size and especially when the "ugly" requirements of real world applications start messing up the abstract beauty of it all. Basically, I perceive -perhaps wrongly- Lisp and similar to be even prissier than Ada and as such, even more likely to result in more of a mess as soon as the problem and environment get "ugly" (aka "untidy" aka real-world) enough.

  5. -----BEGIN PGP MESSAGE-----
    Version: GnuPG v1

    hQEMA0hiZsbZKp+MAQf/SUKIwuai4vloZg1qOXuqteFJajA6vdyUavOuMccmOZnD
    ++VL3g+yazDCnC8WOhDN2fAxFnIJ0hizoD8OrxUaUkQTSj34gxjKO3FTLOJMB0G9
    qZ8Ks01H1Uunjo5Zm2SDVNFvl60H6H+GT4Xvb+tIxeDZV/CwgDYckos7SYCSeTJT
    AmsojKXwbO2trnxo2elPpfhC5M3ptdVbXr0EDZrHFix9yU8RI1DYI6emvI/3q9tC
    EUE1+hw03P1TPB4gEWPPR5eR00FqDGWAXZip0WBhBh8HtHzThlk2hPFGgGE1wy3w
    Zy4V5mPNFT9f6bblMqU8Dh3zWI5BmosTQkfqeEy3TtLAVwG9U2OQOmjnzelSarT5
    C9iggthrFFDGKVe8T6AlYrPDHfKTTkvsPb/WDfTELaj/Sv6YQB9YJQKSBqup2OCg
    Xss3CDs3k12SgAHNObORT0JybZ80HbP/PLG/hKS17lkAQXdNiGWswBpg1jMljWvW
    JBCUU6dkSQ6N+XUqFa4hCf4lLliIaTRyCbOqqVDXOTqm1P41WTFwHQpQr6r53p4y
    TuHJic7IQtkr5LjhKRz9b/iZwN515TvP/XTEVV36y5D0gtdkzgqL+TIXXM6fqal1
    K2y5kfFaYE0vU1+tcyYKjX9eDmT277X7jt50pM85sAuWqwMPivFKIKNj+BohkGI5
    u6W0Z8leVzreWYdMedMy7NDp9xzdpm+XNA==
    =KjJp
    -----END PGP MESSAGE-----
  6. -----BEGIN PGP MESSAGE-----
    Version: GnuPG v1

    hQEMA0hiZsbZKp+MAQf/TuZ4pBX/P9/rFfGmH+9U6d5pM8vl24tp4G/zjlIbNJeb
    jKGfkAPz3dDH1O4t1rEAqLFkRpFC0nSCARz/eWbq0rGkqnYIIs5V7kMKN9v1FtuU
    2gGfSjrkwI/SN7MBDh3Q727fAn7HvrusDguSL67jZOFDHncKhKbAMfiQyKetOLZY
    xehODdH0yVzLMtG4b6hJ5YjlGcpb4/sWd8LoFGBAbm6JhW2YUkRsZj2ZEamr8giy
    xCTARR/yU8I8B2jyi5OtOsGRlw4zjGO6pRNE4B2NiMwQlw+qTWoaGjNd5B3j8bZ9
    YpV/vUGnidBzIn0JP2KL4Zj96TTuI7RpI88gqZd8RdLpAfRdaA0n9i6PAFS54sWl
    fi6i2aUpOqTeytwuQiGjRtfRtxIrchVqwi/k1y7reFkfweYbITsrXZKHtTbuZ9wE
    WPxqKW6B43pqPnbG5acY9d7qO4Ndxd74vJvFU7LjsAel/sRT4Q/73K0/5uUSICMO
    r6bb2W6se0HNVGG540+mmH1xm+vQOwS+HuSPVeZ+elGBxw66OtdQlVr8hgRRbj/8
    jA8Y8euVbkv9EicFPO98esJ1NtjVOV6keehH7ecKMvWdK8tsTtByJ+ImzipDkvuG
    oivnJYvq7SaC+q5b28hTYbiny2ZkCOtmvypq88qW9v980fJtfDshWWUrFwG+zXKX
    l9Yyd/6BJ4T/Akng6eynqHBRqMavuwDZAystfjfPRjbZyHWETjRM+oXoJraPkgb8
    Yveleqsc00rz+PFvA68O604KS3cyIL/hgnNB3bi6DRcmcO+FXxoSG9L6GMYNGoqi
    ZCQBIyFoMN5UWHZ/MAtMpJFyyEVPDl0hf8x6wK2UnM5WytvS6q3msRwuyIJbOHQc
    T6PJaCTGQfDtW8FcdOMedWk/Y5cuf7pPIugg35ul853/2BaZ8MWIEdqH6CSevhhL
    k/5gKFtlfOoD8+lZLd3eagDAwaUG0PFWNZTfc3rq545Xe0pdYlPatMqAAA3Ppdxv
    qnR7YPRQ8ruWa6MwdyY2zgVuN6wGAcJYhVWbXxL2i6thNhkd4RA6OUozdMNJPql9
    Nx5N4BdvYq93jDKdCaUXZe38VgB8Ii9r354z2Wnt1t/9TlzHGdFg3lwoQRWyZCPd
    yTg9tkYxB2xAheAY+83thkXtoI2WTj8R1xmb9HfGc2Y=
    =wEre
    -----END PGP MESSAGE-----
  7. [...] ground has been covered in at least one fully working iteration and the swamps have been all but drained, the core structure is now reliably in place and so the time has come to document publicly at least [...]

Leave a Reply