Page 1 of 1

Coding in new features or bug fixes

Posted: Wed Dec 08, 2004 8:42 am
by tetzlaff
I have successfully installed the required files to build Exult. There are some features/fixes I would like to add in, but I was not sure how to get them perminantly added to the source or if anyone else was interested in those changes.

Before changes are added is there any kind of discussion among the programmers or users?

Right now I am toying with changes to display item counts and stone weights for containers. While playing with this, I noticed that the text can appear under the mouse. I guess ultimately I would like to add extended descriptions on all items and have the text always appear under the mouse. In order to add a feature like this there is a lot of changes or new routines I need to add that is why I want to know what the procedure is to get changes added to the source.

Brian

Re: Coding in new features or bug fixes

Posted: Wed Dec 08, 2004 11:28 am
by drcode
Usually, the first time you want to contribute code, you can send us a patch. If you wish to work regularly on the code, we can give you CVS access by adding you to our group.

Re: Coding in new features or bug fixes

Posted: Wed Dec 08, 2004 4:50 pm
by tetzlaff
How do I submit fixes? I'll post this one because it is a really small fix.

BUG: Right Clicking on Gump with "Right Click Closes Gumps" enabled causes the Avatar to move.

FIX: exult.cc

MAKE THIS VAR A GLOBAL

static bool right_on_gump = false;

ADD THE CHECK TO THIS LINE

if (SDL_BUTTON(3) & ms && right_on_gump == false)



There are actually 2 places to move the Avatar with the right mouse button. The one of the places checks to "close" gumps. The other does not check if a GUMP CLOSE is in progress.

Brian

Re: Coding in new features or bug fixes

Posted: Wed Dec 08, 2004 7:03 pm
by tetzlaff
I'm stuck. I tried to copy a function, rename it, and set all of the .h file references to see the new function. It complies, but when I run exult.exe, it crashes.

The modified files are
"gamewin.cc"
int count = obj->count_only_objects(c_any_shapenum, c_any_qual, c_any_framenum);

"objs/contain.cc"
int Container_game_object::count_only_objects (copy of count_objects)

"objs/contain.h"
virtual int count_only_objects(int shapenum, int qual = c_any_qual,
int framenum = c_any_framenum);

"objs.h"
virtual int count_only_objects(int shapenum, int qual = c_any_qual,
int framenum = c_any_framenum)
{ return 0; }



Even without calling the function in "gamewin.c" the game crashes. I admit I am not a C++ programmer. I have made clean just to be sure.

Brian

Re: Coding in new features or bug fixes

Posted: Wed Dec 08, 2004 10:33 pm
by wjp
If it crashes when you're not even calling the new function, I would guess that you changed something else somewhere...

Note that simply saying "the game crashes" is too vague. At which point does it crash? At startup? When it should be calling the new function? At a random time? Did you trap the crash in a debugger to see where it crashes?

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 12:19 am
by tetzlaff
Good point.
Adding the new function only to contain.cc and contain.h, it crashed when I double clicked my backpack.

When I added the new functions to contain.cc, contain.h, and objs.h, it crashed just before the game window was supposed to load. It crashed while the red cycle screen.

Simply put, I want a function that only counts items, not items + contained items recursively. I was working on displaying extended item descriptions. I want to clean up a few things that I find annoying after playing some newer adventure games like UO, Divinity, or Diablo 2. I understand how to "write" the funtion I want, I just dont know why when I added a new function that it crashes the game. The crash (if it is even a crash) basically unloads the Exult window. Literally, it just dissapears.

P.S. I am very new to editing the source, I just started playing with it 2 days ago. So I am not sure how to trap or trace it. Since it is compiled under some kind of unix shell, I dont think I can do those kinds of things.

Brian

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 1:47 am
by Gunnar
When the game crashes, you should check out stdout.txt and stderr.txt. If you didn't write any info in it and it's your piece of code that crashes it, you won't see anything offcourse, but in this way you can see already if something else in standard exult is going wrong.

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 6:05 am
by tetzlaff
STDOUT.TXT last line:
Loading default keybindings

STDERR.TXT

I played with it some more this morning... and now this time I just want to add a function to the obj.h file. I just copied count_objects and pasted it as count_only_objects. It has a return of 1.

virtual int count_only_objects(int shapenum, int qual = c_any_qual,
int framenum = c_any_framenum)
{ return 1; }

I put it as the last declaration of "class Game_object : public ShapeID"

I then called it as: int count = obj->count_only_objects(.......);

Instead of returning a 1, it appears to be returning a -1...

Brian

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 6:29 am
by wjp
Check your build process. Maybe old object files are still being used.

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 8:01 am
by tetzlaff
I wont be able to try anything until tonight. But when I made changes to objs.h, I put a space at the top of objs.cc so the objs.o would be updated.

Like I said, without trying to write the function, I just tried to declare a new funtion in the header file for that class that just returns a "1". The game did not crash but it did not return "1" either.

Brian

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 8:31 am
by wjp
> But when I made changes to objs.h, I put a space at the top of objs.cc so the objs.o would be updated.

I suggest reading up on building a bit. This is completely wrong and will produce countless 'weird' runtime errors. If you do this, then every other file calling functions declared in objs.h will still be using the old Game_object class since it wasn't recompiled.

Generally you'll want to recompile every file including objs.h (either directly or through other header files) when you update objs.h. (And of course the same for any other header file that you modify.)

I hope this helps,
-Willem Jan

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 8:41 am
by drcode
Your compiler/linker tools should take rebuild whatever is necessary automatically. If you're using gcc, you should just have to type 'make' in the top directory. If using MSVC, a single menu item should rebuild correctly.

Once you get everything rebuilt correctly, you're also going to have to learn to use the debugger.

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 9:03 am
by tetzlaff
I am using the code:

Exult CVS source code snapshot 2004-12-02 00:21 3174 KB


I followed the directions for "To build in Windows using MinGW" in:

README.win32


When I made changes to objs.h, the objs.o file does not get updated, this is why I put a space in the objs.cc.


I only use these 2 lines from c:\exult (Top level of the source)...

make -f makefile.mingw install
or
make -f makefile.mingw clean

Brian

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 6:36 pm
by tetzlaff
Mystery solved!

Willem, you nailed it. I started with fresh code from the .zip. I compilied to be sure I had a "new" start. I made my changes to objs.h. Cleaned the build. It worked. I then changed contain.h and contain.cc to create the inherited function. cleaned the build. And it works now!

Dr.Code. I have a copy of MS Visual C#. If its possible to complie under that, I am sure I can use breakpoints and step through my code. However, I am experienced at programming for embedded systems without the fancy debuggers. If I can display some text to the screen, thats all I need.

Thanks for the help,

Brian

Re: Coding in new features or bug fixes

Posted: Thu Dec 09, 2004 11:09 pm
by Dominus
you can use a debugger with your mingw build. I'm sure someone can point you towards it. They (people on #exult) made me use it once (if I remember correctly) but all the information got lost in my mind.

Re: Coding in new features or bug fixes

Posted: Fri Dec 10, 2004 10:07 am
by drcode
I just use plain old gdb, both on Exult and at work. It's probably included in mingw.

Re: Coding in new features or bug fixes

Posted: Fri Dec 10, 2004 10:42 am
by tetzlaff
DrCode,

Where do I submit my changes to? I am pretty happy with them actually. A summary is: Fixed a right-click close gumps bug. Fixed it so the click-for-info does not show up when doing a double-click. And added extended data to show how many items are in a container and the overall weight of the item. Extended Data is written in red. And finally the info-click never shows the data "under" the mouse pointer.

Brian

Re: Coding in new features or bug fixes

Posted: Fri Dec 10, 2004 11:23 am
by wjp
Submit patches to our sourceforge patch tracker at

http://sourceforge.net/tracker/?group_i ... tid=302335

Make sure each feature/bugfix is a separate patch so it's easier for us to review the changes. If you add any 'new' features which are not in the original U7, make sure they can be disabled (or even disable them by default).

Re: Coding in new features or bug fixes

Posted: Fri Dec 10, 2004 2:04 pm
by tetzlaff
Is there any instructions on how to make a patch file?

About enabling/disabling features... I guess that is the next area of the code to look into. I guess step 1 is to enable with the config file? Then step 2 would be to enable/disable in the main program?

I can understand that extended info is a "new" feature. But actually the way the point-click interface is now, its not 100% like the original. I tested the original to compare what Exult was doing and what I wanted it to do. Actually in the original, the item name appears more up and to the right realitive to the item. Gump's dont give off any information when clicked on. When you click on say a crate, then while the word "crate" is on the screen you click on another crate... The first crate name disapears where as in exult every item clicked on shows the name. Contrast this to when you click on a crate and then click on a bed. Both names are shown at the same time. Double clicking does not show the item name in the original. And finally when you click yourself in the original it actually says "yourself". =)

So if i changed it so that the info appears relative to the mouse, and not the item... Then I guess that is a new feature and it needs to be disabled as well?

Brian

Re: Coding in new features or bug fixes

Posted: Fri Dec 10, 2004 9:15 pm
by tetzlaff
Ok,

I got the configuration thing nailed!

I found yet another level 4 bug. If you click anywhere, then move the mouse to a "double-click" enabled object. It acts like a double clicked happened, but actually it was 2 "single-click" events.

I also threw in a configuration option to turn off Rune signs. After all these years of being an Ultima fan, I still am not into the whole rune thing. =)

I may look into adding plaque text into the extended info single click as well as book titles... (Where will it all end???)

Just need to figure out how to create patches and submit them. Any suggestions?

Brian

Re: Coding in new features or bug fixes

Posted: Sat Dec 11, 2004 2:07 am
by wjp
Look into the 'diff' utility.

diff -u original_objs.h new_objs.h > objs_h.patch

Then objs_h.patch will contain the differences between the original version and the new version.


If you're using cvs you can also use

cvs diff -u objs.h > objs_h.patch

to create the diff.



There's already a cheat to automatically translate runic/serpent signs, by the way. I think you need to toggle the 'read' flag of the avatar in the cheat menu.

Re: Coding in new features or bug fixes

Posted: Sat Dec 11, 2004 6:37 am
by tetzlaff
Thank you. I'll look into the .diff tonight.

Yes, I found there was a way to change the read flag with the Avatar through the F2 cheat menu. It was way to many key strokes for my tastes =).

Lets see, last night I found that if you single click on point, over no item, and drag the mouse to point b, over an item, it would display the info. So I fixed that one too last night.

I want to look into the open gump container problem. I noticed I could open a contianer in trinsic, run over to brit. with the gump still open. Find something I want to "collect". Pick that item up in Brit. put it in the gump container, and it will be waiting for me back in Trinsic.

Brian

Re: Coding in new features or bug fixes

Posted: Sat Dec 11, 2004 7:34 am
by SB-X
That is pretty silly. But isn't that how U7 did it?
Keeping it at the opened container would be like U8.

Re: Coding in new features or bug fixes

Posted: Sat Dec 11, 2004 7:59 am
by Dominus
The original paused on gump open.

Re: Coding in new features or bug fixes

Posted: Sun Dec 19, 2004 8:11 am
by tetzlaff
Sorry I dissapeared for a while. I was out of town last week and I am going out of town next week too... I want to thank everyone for the help. I really enjoy working on this source code. As a test, I will post a patch to fix the "right click on gump moves the avatar" with the "right click on gump closes gumps" option. And I'll just continue from there. :)

Brian

Re: Coding in new features or bug fixes

Posted: Sun Dec 19, 2004 9:03 am
by Dominus
We (if I may speak for tohers as well) are looking forward to it.

Re: Coding in new features or bug fixes

Posted: Sun Dec 19, 2004 2:00 pm
by tetzlaff
Opps.. when I submitted the patch, I forgot to upload a file. Now I understand the process.

Brian

ok...

Posted: Sun Dec 19, 2004 9:08 pm
by tetzlaff
I have listed a whole slew of little fixes. One at a time as requested. The next changes I made affect multiple files.. so those will come next...

Extended info... and an a option to turn off "runes". And position the info realitive to the mouse. Those are all new features.. and I want to make it more like the original and offset the info to display more to the upper right like the original... I should also extend the info on screen time a tad, as the original was like that too.

Brian

Re: Coding in new features or bug fixes

Posted: Sun Dec 19, 2004 9:27 pm
by drcode
Don't apologize for being slow about getting stuff done. Wait 'till you see how long it sometimes takes us:-) (After all, this is all for fun.)