Page 1 of 1

Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 15:56
by khalil
I've found the enum for rods, but that's about it. Does anyone know where their properties are kept?

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 16:15
by BlackSheep
Book-data.h contains the list of spells for each rod (see the comments to find a particular rod). If you're thinking of adding a rod, you'll want to make sure you add it to the end of the list.

(If you're going to try your hand at coding, you should set yourself up with some means of searching the code.)

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 17:03
by mumra
khalil wrote:I've found the enum for rods, but that's about it. Does anyone know where their properties are kept?


Once you have an enum name, it's a fairly obvious step to search across the whole source for any occurrences of that string to see how it is used.

I'm thinking if you want to learn to code, Crawl's source might not be the best place for you to dive in (or for anyone for that matter). It's huge and complex and frequently it's non-obvious how things work; and it's far from being some gleaming example of best practices to follow.

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 20:15
by khalil
mumra wrote:I'm thinking if you want to learn to code, Crawl's source might not be the best place for you to dive in (or for anyone for that matter). It's huge and complex and frequently it's non-obvious how things work; and it's far from being some gleaming example of best practices to follow.

I already know c++, allthough I use it in conjunction with visual studio for most things. Can't use it for this, because it screws up the code somehow. Either way, I'm stuck editing in notepad, which means a lot of my time is spent looking for the missing semicolon.
I have only worked with crawl for a few weeks, and I already hate Linley with a passion. It's like he was trying to make it obscure and impenetrable. Did does anyone know if he started off trying to code it procedurally and switched to OOP halfway through or something? Cuz that would explain a lot.

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 20:33
by BlackSheep
Give Notepad++ a try. It includes a great file search feature, has code collapsing, tabbed viewing, and is compatible with ctags which lets it know where classes, structures and enums are defined.

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 21:30
by galehar
khalil wrote:I already know c++, allthough I use it in conjunction with visual studio for most things. Can't use it for this, because it screws up the code somehow.

You can try eclipse, it's pretty good. Use it only for editing and debugging, don't try to compile with it under windows, it's a nightmare to set up with msys. As blacksheep pointed out, notepad++ is also pretty good. At some point, a good debugger helps a lot and eclipse has a great GUI for gdb.

khalil wrote:I have only worked with crawl for a few weeks, and I already hate Linley with a passion. It's like he was trying to make it obscure and impenetrable. Did does anyone know if he started off trying to code it procedurally and switched to OOP halfway through or something? Cuz that would explain a lot.

It's the first big project he worked on, he wasn't very experienced when he started it. First versions had no enums and used magic numbers everywher! I think most (all?) of the OO parts were added or refactored by other coders with the stone soup fork.

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 22:10
by mumra
khalil wrote:I already know c++, allthough I use it in conjunction with visual studio for most things. Can't use it for this, because it screws up the code somehow. Either way, I'm stuck editing in notepad, which means a lot of my time is spent looking for the missing semicolon.
I have only worked with crawl for a few weeks, and I already hate Linley with a passion. It's like he was trying to make it obscure and impenetrable. Did does anyone know if he started off trying to code it procedurally and switched to OOP halfway through or something? Cuz that would explain a lot.


There's no problem using VS for editing. Crawl has a VS solution in the MSVC directory. It's what I use. You just use msysgit for building instead of VS because the VS build is broken.

A huge amount of Crawl's code is written post-Linley, and a lot of the stuff that uses classes will be more recent, yes. Like I said, Crawl is not a gleaming example of best practices; but hey, it works!

Anyway even if you're just editing in Notepad (you might want to try SublimeText instead though) you can still use grep from msysgit to do a source-wide search. "Search all files" (or "Find all references" in VS) is my standard way of finding out how anything works, not just Crawl.

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 22:12
by mumra
galehar wrote:At some point, a good debugger helps a lot and eclipse has a great GUI for gdb.


... Having said the above, I should actually try eclipse at some point if debugging is fairly painless to set up.

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 22:46
by galehar
mumra wrote:
galehar wrote:At some point, a good debugger helps a lot and eclipse has a great GUI for gdb.


... Having said the above, I should actually try eclipse at some point if debugging is fairly painless to set up.

Well, I didn't said it was painless to set up... It's ok under Linux, some more work under windows. But once set up, it's really convenient. Easier to "attach to a process" than start it from eclipse too. Also, STL Support is awesome, but Linux only for now (needs gdb 7, msysgit has 6.8).
I run windows but use a debian VM to do any serious dev.

Re: Where are rods defined in the source code

PostPosted: Wednesday, 13th March 2013, 23:02
by mumra
I will have a go at some point (I just also saw a gdb extension for Visual Studio which looks interesting). But yes, I really should set up a VM at some point anyway for various reasons!

Re: Where are rods defined in the source code

PostPosted: Thursday, 14th March 2013, 00:47
by khalil
Thanks for all the advice.
I'll try and see if I can get it to work with visual for now.