Where are rods defined in the source code


Questions, Explanations, Howtos

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Wednesday, 13th March 2013, 15:56

Where are rods defined in the source code

I've found the enum for rods, but that's about it. Does anyone know where their properties are kept?

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Wednesday, 13th March 2013, 16:15

Re: Where are rods defined in the source code

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.)

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Wednesday, 13th March 2013, 17:03

Re: Where are rods defined in the source code

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.

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Wednesday, 13th March 2013, 20:15

Re: Where are rods defined in the source code

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.

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Wednesday, 13th March 2013, 20:33

Re: Where are rods defined in the source code

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.

For this message the author BlackSheep has received thanks:
MIC132
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Wednesday, 13th March 2013, 21:30

Re: Where are rods defined in the source code

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.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...

For this message the author galehar has received thanks:
mumra

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Wednesday, 13th March 2013, 22:10

Re: Where are rods defined in the source code

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.

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Wednesday, 13th March 2013, 22:12

Re: Where are rods defined in the source code

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.
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Wednesday, 13th March 2013, 22:46

Re: Where are rods defined in the source code

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.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Wednesday, 13th March 2013, 23:02

Re: Where are rods defined in the source code

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!

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Thursday, 14th March 2013, 00:47

Re: Where are rods defined in the source code

Thanks for all the advice.
I'll try and see if I can get it to work with visual for now.

Return to Coding

Who is online

Users browsing this forum: No registered users and 19 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.