2nd Issue: Hacktober Fest

Hello friends,

This week I had a really rough time finding a issue that I really wanted to work on. I searched and scoured GitHub for issues that were around my level and that I actually wanted too do, which I guess are few and fair between. Anyways, I happened to stumble open one. It was a issue for a game called hag, which is ncurses procedurally generated dungeon crawler. It caught my eye as gamer and it had a issue I felt I could tackle. I commented on the issue that I’d to tackle it and I was shortly assigned the issue.

The Fix

After, I forked the repo and got to working on the issue. There was a lot more code than I anticipated. So I had to hunt down where enemies were being spawn. I looked through the obvious files like enemy.c, player.c, floor.c, gui.c, and main.c. I decided I would just follow along with the logic until I figured out where the issue was. I ended up having to read many different function definitions and going from file to file. I ended up finding where I thought the issue lied. I sent the fix with code below. It checks if the current enemy we are trying to create is equal to coordinates of the current player, if it is don’t spawn.

I was told that this wasn’t effective since we still actually wanted to enemy to spawn and that I should do the check where the x and y coordinates are created. That is what the code below tries to follow.

I thought this was the fix that made sense, but what I didn’t realize that the enemies were placed during initialization. That means that I actually needed to recalculate the stairs so that the player never went up the stairs and a enemy spawned at the same location. This was pointed out to me by the owner of the repository. I then created the following code to fix my mistakes.

This code logic goes as follow:

  1. Create Stairs
  2. Loop through enemy_list
  3. If any enemy is at that generated stairs location, regenerate stairs
  4. Point the list back to the head and loop again
  5. If it never enters the if statement the list is traversed and the stairs stay

In The End

As of 10/12/2019, this is the state of my pull request. Hopefully, the author validates that the code is correct and it gets merged into master.

I felt that was a great learning experience for open source development. I had a great back and forth with the author telling me changes and fixes I needed to add to my code, which I greatly appreciate. I am also pleasantly surprised that he was willing to stick with me and help me figure out the logic I needed to fix the issue.

Published by Neil

I am currently a third year student at Seneca College studying Software Development.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website at WordPress.com
Get started
%d bloggers like this: