Author Topic: Banana Rogue  (Read 10193 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Banana Rogue
« on: April 06, 2019, 10:25:53 AM »
I found Advanced Rogue's source code from random internet website and have been programming it to compile in modern C++. The experience so far has been quite positive. It's incredibly well programmed for that age and being C. The majority of the code compiles fine in C++11, but some things are giving trouble, like function pointers, malloc/free and some macros I think. The biggest task this far has been the missing declarations for functions. For some reason you didn't need those in ancient C compiler, just compile C files and functions are found somehow. Also, function pointers would be ok I guess, but C++ doesn't allow "free style" pointers where every kind of function can be passed in function pointer. C++ requires the function signature to match. But I have a plan to remove function pointers at least from 'options' module. I'm also going to rewrite some things, but try to keep C (procedural) style as much as possible.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Banana Rogue
« Reply #1 on: October 14, 2019, 09:51:07 AM »
When I switched to C++ 17 and used more strict settings there were more errors. Most of errors were produced by register keyword which is apparently no longer supported. Somehow I find this project interesting, because it is quite difficult to fix, but the size (in lines of code) isn't impossible. I decided to replace some old school C string routines with std::string and it does break C compatibility obviously, but it's the programming style I know best. If I get into a point where I can't proceed I'm going to upload this to github I guess. Maybe I should do it already, but first I would have to find some kind of Git gui or learn command line git...
« Last Edit: October 14, 2019, 09:53:06 AM by Krice »

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Banana Rogue
« Reply #2 on: October 17, 2019, 07:42:18 AM »
The way game objects are handled is all over the place, maybe because in procedural programming the concept is more focused on functions. The lists of items and some other things are in rogue.h which is a monolithic piece of definitions. I think it can be broken into pieces without really missing out anything. Most of the difficult problems are unsurprisingly related to use of global data, which can be also relieved by using better data structures like std::vector even though they would stay global.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Banana Rogue
« Reply #3 on: November 09, 2019, 01:37:23 PM »
Rogue.h can be broken into pieces and so far it's been easier than I thought. Many functions are in "wrong" file if you give them some kind of category and the reason is that there is no files for "object" structs since the original code is in pure C. Some data can be placed into 'action' type files that have the actions for that object type, like weapons, traps, potions etc. and the rest for actual files for that struct type (object.h+cpp for object struct, thing.h+cpp for thing etc.). Luckily the amount and type of data structures is quite simple.
« Last Edit: November 09, 2019, 01:39:32 PM by Krice »

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Banana Rogue
« Reply #4 on: May 06, 2020, 05:24:38 PM »
Still working on this one. I think in the end I have to figure out ALL of the data this game has and somehow rearrange it in better way. Or at least in the way I can write a new save/load routine, because it's going to be a tough one. Function pointers are still a problem, because they can't be ported to C++ without strict function signatures. But I'm getting a better idea where and how they are used. In options it's quite easy, the list of options simply have bool, int or string values with function pointers to get and set them. That whole thing can be replaced with a class that's holding options. In the current implementation options in the list are pointers to global data, well, because everything is global in this project.