Skip to main content

Vehicles with a Broken Frame

Browsing through github projects in C/C++

Trying to find ways to link up the goblin_camp project with more automated testers, I started looking around the Readme.md files of other C/C++ projects in github. From neovim, I found AppVeyor, and although I have not yet set it up, it promises to supplement Travis CI with Windows test builds. I also found Coverity Scan, which might be a way for us to scan the large, preexisting code and fix goblin_camp. Then, from Cataclysm-DDA, I found Bounty Source. The icon had a dollar figures on it, so I assumed it was some sort of funnily-named fund raising site. It was, but with a twist.

Show Me The Money

Apparently, this site is designed to help the project by having people put down money into a pot to fix certain issues listed in Github. Some of the issues were very popular: enough people contributed to the pot of 250 dollars. I would also imagine those are tough ones. I found myself a less-popular, 4 year-old issue of 15 dollars. I am more than certain the task will take more than an hour, so the pot won't even cover the minimum wage. Still, I always wondered if my skill and code were good enough for anyone to pay for it. I guess I'll find out.

The Issue

The game is rendered in a very blocky fashion. As such, things get tricky when the game needs to represent a diagonal walls. This was especially an issue with cars. As the car turns, say, 45 degrees, the car is now standing diagonal and the walls of the car starts to behave oddly: not only can you see through them, you can walk, shoot, get shot, get eaten through the wall. While not such a big deal in terms of game balance or general game play, it did break realism, even if everything is in ASCII.

Proposed Solution

After reading through discussions and associated rants and name calling, one of the members proposed a workaround. It wasn't as elegant as some others, but it seemed simpler to implement with small game play impact. Essentially, when the vehicle enters diagonal directions, new walls spawn along the side of the cars that will ensure the wall stays unbroken. This means the car suddenly gets fatter when turning and then skinnier when not diagonal, but it might be worth-while to code and see what kind of game play effect it has on different plays.

Details and PR

The vehicle.h contains a wealth of information on the behavior of any given vehicle. It also have a member object, called face_dir, that can be used to check if the vehicle is at a given angle. It also has a method, called turn(), that changes the angle. It also has vehicle_part object that represents the type, position, and other states of each building blocks of a vehicle. The idea is to create a derived class of vehicle_part, named sentinel_part, which will have a pointer to the original object. Some discussion suggests that may be insufficient, so this may change, but in one form or another, the sentinel_part will be linked to the side wall it is supposed to mimic. Its constructor will perform a shallow copy from the source, and its destructor will shallow copy the information back. This way, any changes that takes place to the sentinel_part will reflect back to the original, albeit in a delayed fashion. The parts will be spontaneously installed to location just outside of the side walls when turn() modifies the angle enough such that face_dir.deg() returns value within a certain range. It will also check if the sentinel_part is already installed or already removed before performing the actual installation.

The Head-scratcher

My current stumbling block is how to figure out which parts to actually clone. It needs to be the side walls in any angle. My guess is that, if I can get a cross-section of each layer of the vehicle along the x-axis, I should be able to figure out the max and min of y, and use that information to spawn in the appropriate sentinel_part. I could perhaps also store them into a vector for easy removal as well. I also should probably not clone non-wall elements that happens to be on the sides, too. Furthermore, I am unsure what would happen to stored items on those tiles. I guess I will find out.

As of now,

This is going to be an interesting challenge. I am trying to take in a lot of information and understand the moving parts. Thankfully, some of the active developers took an interest in my plight and have given me detailed feedback. That, of course, spawned even more questions in my head, but I am certain I will have fun solving them.

Comments

Popular posts from this blog

Creating a patch for GNU GCC using Git

Overview and Target Audience The GNU GCC project followed a blend of a traditional method with contemporary git tools when it comes to contributing code, making the experience unique from some other, git-based projects. This blog post will explore different aspects of the process, helpful commands, and various scripts that would make the experience more pleasent for new contributors. While this blog aims to help new contributors get acustomed to the GNU GCC code culture and make contributing easier, it must be stressed that this is not in any way in-depth exploration of the process. This should help you put your first foot forward; the community will help you take the rest of the steps from that point on. This post also assumes the user is in a POSIX environment (e.g. Linux, FreeBSD). Git and GNU As stated in this phoronix post , GNU GCC made a full transition to git early 2020. As of this writing, the community seems to be adjusting to the new tools. GNU GCC hosts its own git serve

Setting up IRC

About IRC Internet Relay Chat was once the most popular real-time communication method that uses computer for a large spectrum of community groups. While it has largely been supplanted by more contemporarly methods for most people, IRC is still a prefered means of communication among older software projects like GCC. The Client As an old technology that is also very favored among programmers, IRC has many clients with different flavors, from GUI to CLI to headless. As a linux user with strong attraction to tmux, I chose weechat. Depending on your distro or OS, install your client first. Configuring Weechat I will be using GCC channel in OFTC server as the example. How are we configuring this? While Weechat has a configuration file, Weechat officially advises against using the file to configure the program behavior. Instead, it promotes `/set` dialog within the client to set the proper configuration. Connect to server Let's first connect to server. The `#gcc` channel is host

Debugging with GCC: GIMPLE

GCC and GIMPLE One of the very first thing GCC asks the GSoC applicants to do, even before writing the application, is to try various different debugging techniques using GCC. I was personally familiar with the basic, compile-with-g-flag-and-use-gdb method. Turns out, there's more: GIMPLE. A Simple but Non-trivial Program Problem Description The instruction asks to compile a simple but non-trivial program with some flags that generates debugging information: -O3 -S -fdump-tree-all -fdump-ipa-all -fdump-rtl-all . Because I was keep reading on ways to debug GCC just prior to the statement, I immediately thought "GCC" and tried make -j8 CXXFLAGS="-O3 -S -fdump-tree-all -fdump-ipa-all -fdump-rtl-all" . This was a mistake: turns out, GCC can't be compiled with those flags. Thankfully, GCC developers have a very active IRC channel for me to signal SOS. Resolution jakub and segher were quick to respond to my call for help. jakub: it isn't meant that y