Multiple Problems, as well as multiple headaches...

Posted by Toy on Wed 16 Apr 2003 02:12 PM — 11 posts, 34,926 views.

#0
Ok. I've been working on my code for awhile now. I've added snippets here and there and I've run into some problems with the code. Seeing as I'd rather fix them then scrap and start over (again), I'm gonna list some of these problems, and hopefully someone will be able to *AT LEAST* be able to point me in the right direction.

-Problem 1: Something is screwy with my area files. Even up to the point when the AreaEditor can't read them. I don't think I've added anything that effects areas to the mud cept for a Editor snippet I downloaded.

-Problem 2: Might be tied in with problem 1. I added a snippet that changed an object's value5 to it's level, so whe it reset it'd reset to a specefic level. Now, whenever I save an object, like objvnum 125's value3 to match Grimm's Weapon snippet, after a reboot, the values don't save.

Problem 3: I'm running into errors with commands. I added a Cshow snippet that allows you to either show or not show commands. Don't know if it's caused any troubles, but some commands, even after I save them correctly and then work, lose their code when the mud restarts.

Problem 4: The races/classes/commands are screwy. For the races and commands, when I save them in the mud, normally the files are lined up nicely, but after a save, their fields are all over the place. And with the classes, when I save a skill, in the classes files each class is given every skill, weither they normally would know it or not.

Anything I can do to figure this mess out, or am I screwed?

-Alexander
USA #1
Let's see what we can do here ;-)

Problem1&2: They're likely tied in together. Any changes to the way objects save would definitely affect your area files. However, what exactly is "screwy" about the areas? Post some errors you may be getting or something.

Problem3: I'm not familiar with the Cshow snippet, so I'm not certain what it may have changed. In stock Smaug however your symptoms have an easy fix. In tables.c you should find 4 total refrences (on 2 lines) to each command. You're either A) missing one or B) misspelled it.

For example if you search for do_aassign, you find:

if ( !str_cmp( name, "do_aassign" )) return do_aassign;

That line, in comparison to commands that may not be saving should be good, otherwise you wouldn't be able to cset the command in the first place. It'll be located in a case statement of other functions that start with the same first letter. Next you find:

if ( skill == do_aassign ) return "do_aassign";

This is the line that's likely misspelled or missing. It'll be in a long list of ALL of the command functions.

Problem4: err.. by "all over the place" you mean in the actual files? i.e.

Name Boborak
Level 105

If that's the case, that's how the individual save functions are writing it. It's common in "messy" code and shouldn't really be a problem. Simply spacing. the skills thing is a bit odd though.

All in all, you do have a nice set of 'issues' here. Some of them appear rather serious. Generally, I'd reccommend to just keep tinkering with it, and maybe re-read the snippets and make sure you didn't skip a part or something. You'll learn from the experience at the very least. Anyway, post follow ups and we'll see if we can't clean up your code without you having to start over ;-)
Australia Forum Administrator #2
You need to be cautious with these snippets - even adding one extra number when writing the area file could well make it unreadable, including by the Area Editor, which expects stock area file formats.

The snippet should also change the way the area is read back in, if it changes the way it writes it, but be warned that you are throwing away your ability to use the area editor if you use such things.

As for file layouts, I agree with Boborak - computer-generated code will always write things "its way" regardless of how nicely you format the file by hand.
#3
Ok, I re-downloaded the Area Editor. Not really sure what changed, but this new upgrade seems to be reading the area files alright.

As for what I mean about the code being screwy, when I save races/commands, it simply moves the field over. Like:

Name '~
Code do_say
Position 106
Level 0
CShow 1
Log 0
End

Nothing major there, but I'm horribly anal. :)

As for the c-show snippet I downloaded from http://www.mindcloud.com/smaug/. I don't know if it's causing issues or not.

My biggest issues come from the items and skills issues. When i'm in the mud, if I type sset save skill table, it creates a 'phantom' class, with no name and everything set to 0. it also gives everyclass each skill, weither or not they should have it. And for the objects, I used a snippet which I'm trying to refind that that changed value5 of an object to it's level, so it'll repop. problem is, as I said, I'm having a hard time trying to refind the snippet.

I'm going to search for a bit for the snippet. I'll repost when I find it.

-Alexander
USA #4
The Cshow snippet is cleanly written and doesn't really do a whole lot. So it shouldn't give you any problems considering you followed it right ;-)

..and if you're THAT worried about the looks of the files, find the function save_commands() in tables.c and fix the spacing the way you want. For example:


            fprintf( fpout, "Name        %s~\n", command->name          );
            fprintf( fpout, "Code        %s\n",  skill_name(command->do_fun) );
            fprintf( fpout, "Position    %d\n",  command->position      );
            fprintf( fpout, "Level       %d\n",  command->level         );
            fprintf( fpout, "Log         %d\n",  command->log           );


;-P
#5
Well, it's been a fun day. :)

I've fixed the 'little' descrepancies with the .dat files, and I've also fixed the object saving issue. One of those opps, that's not right type scenarios.

Now, my major issue left is this little thing:

The problem with saving skills. I haven't added any snippets or changed any code that would effect sset save skill table, so I have no idea why it's doing what's it's doing.

Has anyone run into or heard of saving skills making a 'phantom class' and giving every class each skill, including reserved?

-Alexander
USA #6
Hmm. Are you using Cygwin? This may be a good time to learn how to use gdb. Also, in tables.c, review the function save_skill_table() and see if anything looks wrong. If you want post it here so we can take a look at it. Don't forget to add a [code] and a [\code] at the top and bottom so it's halfway readable ;-)
#7
ok, here's that section. Mind you, my coding setup is different and so are my levels, so here we go:


    	if ( get_trust(ch) > LEVEL_CODER && !str_cmp( arg1, "save" ) && !str_cmp( argument, "table" ) )
    	{
	if ( !str_cmp( arg2, "skill" ) )
	{
	send_to_char( "Saving skill table...\n\r", ch );
	save_skill_table();
	save_classes();	    
/* 	save_races(); */
	return;
	}


Is that what you are looking for?
-Alexander
USA #8
Yes and no. That was the section of code I was reffering too, but it's not what I was looking for. It appears we need to look at the save_classes() function now. I haven't a clue where that may be located, my code doesn't have it. I'll find a distro that does and take a look at it.
USA #9
Ok. I downloaded a distro that had the class files and here's what I've noticed. Your 'phantom' class is getting created in load_classes() on boot. There's a bit of code at the end of the function that creates a blank class for each class that hasn't been loaded, up until MAX_CLASSES. Have you changed the value of MAX_CLASSES (in mud.h) or removed any classes from the class.lst file?

As for the skills problem. It appears any skill who's level is less then that of LEVEL_IMMORTAL will be written to a class file. There could be multiple reasons this is occuring. First take a look at an individual line in your class files. like this:


Skill 'cause critical' 9 95


The first number is the number that determines if the skill should be wrote to the file or not. If this number is higher then LEVEL_IMMORTAL it should never have been written according to the stock code. If all of these numbers are low but identical (i.e. all 0 or all the same number) you could have another problem with the write function or maybe even a read problem. It's hard to say exactly where things have gone wrong, but post a few lines of your skills in the class files so we can have a look see.
#10
I've run into strange issues when it comes to things like MAX_CLASSES and MAX_RACES. I've got 25 races right now, and 9 classes. If I set the numbers in mud.h to equal that, I get error messages when I turn the mud on saying it couldn't find the class or race, just the last class/race below the max. If I make the number higher, it's fine. I've got both set to 100 right now, having no issues other then the skill issues. I've removed all the MAX_CLASS -1 and MAX_RACE -1 calls, yet still, I lose the last class or race.

-Alexander