TONPPAMF

The Official NPPAngband And NPPMoria Forum

You are not logged in.

Announcement

November 28, 2016 - NPPAngband forum has been migrated to a new host. SSL has been enabled so please use https:// if possible.

#1 2013-11-29 07:20:04

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

NPP 8.0.0

Just an update.  I am working on learning QT and a little C++ and should start work on NPP 8.0.0 very soon.  It is going to be a complete overhaul of the GUI and back-end on NPP. Hopefully a whole lot of things in the game are going to work much better soon.

Offline

#2 2013-11-29 08:49:04

camb
Member
Registered: 2006-01-29
Posts: 705

Re: NPP 8.0.0

Sounds good. Look forward to it!

Offline

#3 2014-01-03 16:14:58

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

I am making progress, and I think I got over one of the hardest hurdles, having the QT port correctly read all of the edit files.  The game use Unicode fonts from now on, which will make some things much easier.  (@RunningAway - this required almost a complete re-write of init.1, now called init_edit_files.cpp.  If you are ever again inspired to work your magic and your proofreading skills on a file, can you please make it that one?  It seems to work correctly, but it is pretty much 3000 lines of code written from scratch.  Somewhere in there is almost certainly a cut-and-paste error or typo on my part that will cause filthy street urchins to cast nether bolts or something like that. 

The next step is to go to 24 bit color read and then have the game read and save a savefiles. 

The beginnings of the port is here:

https://github.com/nppangband/NPPAngband_QT

Offline

#4 2014-01-04 16:22:29

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

Sure.
I have gone through about half of it, and no problems so far.

I do have some suggestions.  Since this is C++, take advantage of what it has to offer.
* Overload the process_n_ints() functions to process_ints() and the number of parameters selects which one is used.
* Use reference (&) variables/parameters.  Instead of int *x, use int& x.  It's still a pointer, but the pointerness is hidden, so instead of "*x = y", you just write "x = y", and it has the same effect.  player_type& p_ptr means you use '.' instead of '->' to access its members.  It just makes the code cleaner.  FYI, "int* x, y" is the same as "int *x, *y".
* Your comment style is inconsistent.  For single line comments, pick one style or the other.
* When I was playing with this kind of conversion, I created a char_attr class that held a character+attribute pair that could be passed or, especially, atomically returned.  In C++, a lot of the processing on characters/attributes could then be moved into it as member functions.
* Consider using CamelCase for functions and variables.  I'm glad you're staying away from Hungarian notation.  Please continue to do so.

Offline

#5 2014-01-04 18:35:32

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

RunningAway wrote:

Sure.
I have gone through about half of it, and no problems so far.

Thank you very much.

RunningAway wrote:

I do have some suggestions.  Since this is C++, take advantage of what it has to offer.
* Overload the process_n_ints() functions to process_ints() and the number of parameters selects which one is used.

I am still quite new to C++.  I understand that conceptually, I have plenty of learning to do.

RunningAway wrote:

* Use reference (&) variables/parameters.  Instead of int *x, use int& x.  It's still a pointer, but the pointerness is hidden, so instead of "*x = y", you just write "x = y", and it has the same effect.  player_type& p_ptr means you use '.' instead of '->' to access its members.  It just makes the code cleaner.  FYI, "int* x, y" is the same as "int *x, *y".

Good to know.  I will do that.  I didn't try anything new with the edit file parsing code because it is so frustrating to try to de-bug.  If it was simple linear code that I would go through it step-by-step, I will try out some new things.  But the code that parses the edit files might work right 99 times out of a hundred, and it was painful to figure out why it would work right through so many iterations and then fail.

RunningAway wrote:

* Your comment style is inconsistent.  For single line comments, pick one style or the other.

I think that's because it is a blend of old and new code.  My new comments use '//'.  The ones left over from init.1 use /*  comment */

RunningAway wrote:

* When I was playing with this kind of conversion, I created a char_attr class that held a character+attribute pair that could be passed or, especially, atomically returned.  In C++, a lot of the processing on characters/attributes could then be moved into it as member functions.

I just updated the Color code today (uploaded a couple hours ago).  QT has a typedef called QCOlor I am using that has many useful methods.  I did have to use some unusual pointers and return functions to get things working. 

RunningAway wrote:

* Consider using CamelCase for functions and variables.  I'm glad you're staying away from Hungarian notation.  Please continue to do so.

QT uses all CamelCase.  It thought it would be a good idea for me to continue to use the function_does_this style so I could quickly tell the difference between a QT function and something I wrote.  I hadn't heard of Hungarian Notation, but after reading about I completely agree.

After I do the savefiles, then things get interesting.  I feel like the dungeon should be its own class, and most of the keyboard commands should be signals under that class.  I think the main advantage of this is if I set it up as a QT objet, QT will automatically update the screen whenever something changes.  But I am still quite new to this.  I still don't quite have the hang of how to set up a class with public functions so data can be read or changed by other parts of the code (such as a monster moving from one square to another).

Offline

#6 2014-01-04 19:19:44

CyclopsSlayer
Member
Registered: 2007-10-22
Posts: 104

Re: NPP 8.0.0

Cool! Can't wait to see what comes out. NPP has long been my favorite flavor, and just keeps getting better.

Offline

#7 2014-01-04 19:42:16

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

Keep in mind, I haven't tried running it.  Does it run?

Understand that my C++ is a little rusty, we don't use it at work.  Most of my OO stuff is Java, so my examples tend to look like that.

Generally speaking, if functions do about the same thing but with different parameters, you use the same function name, and the compiler sorts it out.  So moveTo(Point p) and moveTo(int y, int x) are expected to do the same thing.  More than likely, moveTo(Point) is just a wrapper that calls moveTo(p.y, p.x). Internally, the C++ compiler adds some characters to the end of the function name in its linking table that tell what parameters it uses.  If you see function names followed by @ and some gibberish-looking characters, that's what going on.

As for the init code, I actually enjoy writing parsers, it's one of the things I do at work, and what you've done looks fine.  Some differences in style, but not too different from what I would do.  Of course, I think XML is a better format.  There are libraries that do all the heavy lifting for XML.

Converting Angband's neolithic C string handling into something modern strings is going to be the biggest chore.  Just trying to figure out what it's doing in the first place...  Evil use of pointers.  QString looks like it has a nice set of functions.

I bet QColor supports alpha (transparency), which has the potential to do neat stuff.  See-through invisible monsters, for one.

The other real fun is going to come when you rearrange everything into classes.

Anything you declare in the "public" section of a class is fully accessible to to all code.  Anything "private" is only accessible to members of the same class.  Anything "protected" is visible only to that class and to classes that extends the class.  That's how it works.  A struct is the equivalent of a class with all members public and no functions.

So, for starters, replace all instances of "struct" with "class" and put a "public:" at the beginning.  Then get rid of the typedefs.  Everything should work as before.

The Windows API is 100% Hungarian notation, and it it does help with that steaming cesspit, but otherwise, it sucks.  Be glad for the abstraction of QT.

For signals, set up message-passing using listeners and senders (the exact names vary).  In other words, the player_type should be a listener for the PU_* and PY_* messages, and anything that sets the PU/PY flags should instead create an event with those flags and dispatch.  You'd use something like add_player_update_listener(p_ptr) to register p_ptr, then use dispatch_player_update(new player_update(PU_STATS | PU_HITPOINTS)) to send the message.  There would be a p_ptr.handle_update(player_update) that is called by the dispatch_player_update() on all registered listeners (it's a queue) to do the processing.  Unless the dispatch starts a separate thread, it's all synchronous.  Takes a bit of setting up, but it's usually worth it.

The one thing that's really going to bite is memory management.  I like garbage collectors, and unless QT provides one, C++ doesn't have one.  So your new's and free's must be balanced.  Good luck.

Offline

#8 2014-01-04 20:28:37

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

RunningAway wrote:

Keep in mind, I haven't tried running it.  Does it run?

The game opens, closes, has a FILE menu to start a new game of NPPAngband and NPPMoria, opening an existing savefile, dialog boxes for save and save-as on an existing game, closing a game, and closing the program.  It also has a toolbar with icons for all that.  The non-applicable commands (save a file when the player has not opened one yet) automatically dim on both the menu and the toolbar at the appropriate times.  And when you start a new game either game it reads the appropriate edit files, makes the right sized arrays, and loads all of the data.  When you close a game it deletes all the arrays so the player can switch between games without having to close the program.  That's all I have so far.  I don't think it is worth anybody's time to actually run the program at this point.

RunningAway wrote:

Converting Angband's neolithic C string handling into something modern strings is going to be the biggest chore.  Just trying to figure out what it's doing in the first place...  Evil use of pointers.  QString looks like it has a nice set of functions.

Definitely.  QSTring takes care of all the string handling headaches, as do many of the other Q{variable} types  .  I just checked out this link.  It has all kinds of ones I hadn't thought to look for (QList, for example.  I'll bet that would make management of all the lists, such as monsters, objects, effects, much easier.

http://qt-project.org/doc/qt-4.8/datastreamformat.html


RunningAway wrote:

I bet QColor supports alpha (transparency), which has the potential to do neat stuff.  See-through invisible monsters, for one.

Yes, it does handle alpha transparencies.  I was thinking of reducing the alpha making the see-through invisible monsters, effects (smoke clouds, fog, etc), hidden monsters, etc. 

RunningAway wrote:

The one thing that's really going to bite is memory management.  I like garbage collectors, and unless QT provides one, C++ doesn't have one.  So your new's and free's must be balanced.  Good luck.

 

I am double-checking myself on that one..  QT works with Valgrind, so I will run that soon.

The one thing I realized is that I can no longer do a simple memset WIPE of objects and monsters once I start adding methods to the various arrays  I have to see how C++ handles that.

Offline

#9 2014-01-31 12:40:39

camb
Member
Registered: 2006-01-29
Posts: 705

Re: NPP 8.0.0

How is it going? Just wondering whether there'll be anything to test soon, or whether it's more a long term thing.

Cameron

Offline

#10 2014-01-31 21:45:41

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

Making good progress.  I am converting a lot of the backbone code.  Diego is working on the front end.  We are close to being able to get the player through the startup process.  Which doesn't sound like a lot, but it takes probably half of the code in the game to 1) start up the player 2) initialize all of the edit files 3) allow the player to choose race, class, and calculate his starting stats 4) create the town 5) stock the stores (keep in mind it takes thousands of lines of code to generate a single object).  6) create the town (which means the complete feature system must be in place.... 7) create town monsters and place them in the town, and finally 8) show it all onscreen.

So at that point there would still be no 1) handling of commands 2) processing of monsters  3) character screens or character files generated 4) combat  5) graphics, pref files, or macros   7) multiple windows 8) knowledge screens

So overall, I would say we are more than halfway to a basic, playable game.  Maybe 1/3 of the way to having a beta of a fully playable game.

Offline

#11 2014-03-09 18:48:24

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

Been quiet waiting on progress.  I've been peeking in on the source changes

I wouldn't mind testing, but I haven't done a QT build of anything on Windows.  I think I have all the Cygwin libraries loaded.  Just need to git clone.

Any chance of adding links to these to the top of the page?

Last edited by RunningAway (2014-03-09 23:32:36)

Offline

#12 2014-03-10 06:06:42

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

At this point, the only way to play around with it is to install QT (which is quite simple, it all self-installs).  We will have to do some re-configuring before it will be ready to play stand-alone on another machine without QT.

When QT is installed, it installs a compiler as part of the install (WINGW on windows, or Clang on the Mac). I am sure it works with Cygwin, but I have not tried it.  Compiling the game in QT is real simple as well.  You just open QT, open the project file (NPPQT.pro), and then click "run qmake", then "make".  Right now there are hundreds of compiler warnings, mostly due to unused variables due to functions having a single line of code commented out for a part of the code we have not yet installed, but it works.

We are getting much closer to something that can be playtested.  Last week we put in the object selection dialog box, targeting, and about 5-6 of the object based commands (drop, inscribe, uninscribed, wield, inspect, and take off).  We also have the basic movement commands.  There is a message bar, but no sidebar.  Also, there is no character screen, or ability to view your equipment/inventory, besides using the "inscribe" command, and no wizard mode to test a lot of the game.  The store does not yet have an interface, and the commands for going up and down stairs have not been added yet.  All the player can do is walk around town and kill townsfolk.  The next step is the spellcasting menu.  I am working the menu, while Diego finishes targeting and the projection code (the code that actually casts a spell). 

But from a playability standpoint, things are going to start happening quickly.  Most of the core files have been installed and we are working on the GUI and command input.  I don't think a basic, playable game is too far off.  Some key features would still be missing (knowledge screens, character dumps, multiple windows), but the game will be playable soon.

Offline

#13 2014-03-10 16:47:06

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

The one big problem I ran into is that I can't seem to find QtWidgets in Cygwin.  If you could let me know what include directory it's located in, that would be a big help.

It's definitely going to take some adapting to make it work without the QT program.  The lack of a makefile, for one thing.  Also, the 'src/' in #include "src/npp.h" messes things up.

Other than these glitches, it seems to be ok.  Looks a lot cleaner than before.

I'll give it a look over and post in the bugs forum.

Offline

#14 2014-03-10 18:16:10

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

I don't think it will compile without installing QT.  And yes, it uses a .pro file instead of a makefile.  If you can get it to compile with Cygwin, it would be a painful but spectacular achievement.  QT Widgets is, essentially, the QT header for every different type of widget.

Offline

#15 2014-03-10 19:00:51

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

Cygwin has QT.  I installed all of the qt and devel libraries, I think.  It has every other QT header but this one.  Knowing what include subdirectory QtWidgets is located in might help me figure out which one is missing.

qt_mainwindow.c is a hot mess without this header, but it seems to be the only one.

Offline

#16 2014-03-10 19:11:19

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

QT widgets is added in the NPPQT.pro file (essentially, the QT makefile).  I don't know if it can be added as a header file.

I *think* if you went through every line of code in qt_mainwindow and added the header fiel for every type of variable starting with a Q, it might work.

For example, for the first couple functions, you would have to add:

#include <QColor>
#include <QGraphicsRectItem>
#include <QGraphicsItem>
#include <QString>
etc.....

Offline

#17 2014-03-10 19:55:54

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

Ahhhhhh....

Which means that I could just copy the QtWidgets from the QT website.  Since it's not a library in and of itself, but just an aggregator.  Will try that.

Offline

#18 2014-03-10 20:31:11

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

OK, but just to give you fair warning, we are going to QT deliberately to have "one port to rule them all".  On the github repository we aren't going to support compiling or working with any another port or compiler except the main QT program. 

I do encourage you to load up QT.  It is much simpler than what you are attempting.

Offline

#19 2014-03-11 14:29:13

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

QT is a huge download.

Anyway, compiles, runs under QT.  You need to put together a file that tells you how to configure QT so it will build and run.  The key thing being where it puts the executable.  Doesn't take much, but it would save others from having to poke around.

Offline

#20 2014-03-11 17:06:39

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

RunningAway wrote:

QT is a huge download.

Anyway, compiles, runs under QT.  You need to put together a file that tells you how to configure QT so it will build and run.  The key thing being where it puts the executable.  Doesn't take much, but it would save others from having to poke around.

We have not completed the configuration, that's why nothing is written yet.  As noted above, it is still alpha code at this point.

Offline

#21 2014-04-13 08:46:55

RunningAway
Member
Registered: 2012-02-27
Posts: 246

Re: NPP 8.0.0

Are you going to add a health bar to the player symbol like you do for the monsters, or are you going to implement hp_changes_color?  Or both?

Good progress so far.  It is almost playable.

Last edited by RunningAway (2014-04-13 08:47:45)

Offline

#22 2014-08-02 12:16:03

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

I just wanted to let everybody know about the sudden stop in development.  For the last several months I have had several extremely important issues in my private life that require almost all of my time and energy.  It is not a permanent situation.  Things should be resolved in another month or two.  Diego has some projects he had to finish as well. 

We have not forgotten about NPPQT.  In fact, every time I pick up my Ipad I get a little annoyed that I can't play NPP on it, so this project will get done.  Just not quite in the timeframe I had hoped.

Thanks again for all the support, suggestions, and playtesting you all do.  I hope to provide you all a buggy version of NPP that crashes occasionally in the very near future. wink

Offline

#23 2014-08-12 00:59:55

CyclopsSlayer
Member
Registered: 2007-10-22
Posts: 104

Re: NPP 8.0.0

It's alive! Bwahahahahahaha!
Was starting to fear you had gone the way of all good things! smile

Just the other day an article over on HardOCP reminded me that I first discovered web browsers as I was checking for a patch to NetHack or Angband in ~1990/91.

Offline

#24 2014-09-12 23:45:46

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: NPP 8.0.0

I just posted my first commit of a new feature in several months.  I am happy to say I am starting up again.  Looking forward to finally getting to the playtesting stage.

Offline

#25 2014-09-14 04:58:38

camb
Member
Registered: 2006-01-29
Posts: 705

Re: NPP 8.0.0

Excellent! Look forward to any updates.

Offline

Board footer

Powered by FluxBB