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.
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
Post a Comment