View Single Post
Old October 31, 2019, 17:30   #1
Marco
Rookie
 
Marco's Avatar
 
Join Date: Oct 2019
Location: Italy
Age: 59
Posts: 7
Marco is on a distinguished road
Smile Datafiles, refactoring parsers and game initialization?

Hi ,

as my first post, I have quite a lot of things to tell. First of all thanks to all the people who contributed and mantained Angband over the years.

I met the V Angband code around the 3.x versions, on my glorious Amiga. I planned in the past to do great solo things in Angband development, but you know what is the end of great individual plans, moreover if one don't knows at all what a rogue-like game is , so all I did was visiting sometimes the sites and the forum, downloading some updated versions, and having a look at the evolution of the code.

In these days I'm sick at home, so I started again to play with Angband source code with a more realistic approach... I setup a dev environment on my Win PC (Mingw/Cygwin, CodeBlocks, local SVN), forked my copy on GitHub, subscribed the Forum and checked the IRC channel. I'm experienced in C/C++ and other languages development, I like O.O. programming, code organization and refactoring. I hope I can contribute on the last two themes, if I will not be completely distracted again by future life and work events. BTW, over the years I had no advancement in undestanding what a rogue-like game is . I'm also totally new at Git/GitHub and, surprisingly, IRC.

Sorry for the long OT introduction. Turning back to the subject, I took a look at the game initialization and datafiles parsing. I had to write down a list/map of all this stuffs, because I got lost several times wandering the code:

I don't know if what follows is a concern on not, debated or less, and if someone is working on this. IMO, a few points:
  • The stores and dungeon init/parse functions could be merged at the tail of the others array initialization and cleanup, in the pl[] array (init.c). It seems to work. The init_modules store_ and generate_ would no longer be necessary
  • All the File Parsers could be grouped in a few init-something files, like i.e. the z-something and ui-something groups, just to better separate and identify this support functionality from the main game logic. The issue, I think, is moving things away from old files, where people is used to found them, to other or new files . It is a problem to increase the number of .c/.h files?
  • The FilePaser struct could comprise both the filename to parse (the current unused 'name' field) and the description to print (Initalizing... /Cannot initialize ...). Or both could be placed in the pl[] array? I implemented the first solution.
  • The grab_something functions could be moved elsewhere, because they don't deal directly with datafiles, but I can't figure where. Maybe in parser.c, as ancillary parsing functions?
  • I also would like to better clarify in the code the roles/relations of (basic) Parser and FileParser, the latter sitting on top of the former one. There is something that escapes me, but I can't grasp exactly what. My fault maybe

Ok, it is more than enough. Thank you for following me until here . Any comment is really appreciated .

If any of the previous points is of interest, I need some help to clear up minor doubts and eventually submit the changes. Anyway, I had my fun and pleasure in exploring the always interesting and challenging Angband code, and in letting you know . Conversely, let me know if I can contribute in some other way.

Hugs, Marco.
Attached Files
File Type: txt Angband-4.2.0-Datafiles.txt (4.5 KB, 74 views)
Marco is offline   Reply With Quote