22 Feb, 2010, triskaledia wrote in the 1st comment:
Votes: 0
I've been trying to code a way into the MUD that prevents levels below 5 from saving.
In do_save I did if(ch->level < 5) return, tried doing the same thing in save.c where the fwrite_char
thing is defined, and it still saves the player, but with a corrupted pfile because Im blocking the MUD from
saving any of the chars data. Been searching around for a way to prevent them from saving, but I'm not
finding what I'm looking for. So, what I'm asking is if anyone knows how to prevent those players from saving
at all.
Any help appreciated.
22 Feb, 2010, David Haley wrote in the 2nd comment:
Votes: 0
You'll have to abort the saving process before the file handle is opened (which will squash the pfile). You can prevent usage of the do_save command by using command levels (see cedit) or by introducing an if statement into the do_save code. There are several automatic saving points that you'll have to find and prevent as well if you do it that way; it is better to abort it where you're actually saving. (Just make sure to do it before opening the file, again.)
23 Feb, 2010, Koron wrote in the 3rd comment:
Votes: 0
David Haley said:
There are several automatic saving points that you'll have to find and prevent as well if you do it that way; it is better to abort it where you're actually saving. (Just make sure to do it before opening the file, again.)

This. You should have a setup something like do_save() which calls save_char(), but there may be automated calls just to save_char() in your code. You'd probably want to put checks in both places, with the save_char() check being silent, while the do_save() call gives the player a message, "You're too noob to save. Stick around for a while."
24 Feb, 2010, triskaledia wrote in the 4th comment:
Votes: 0
Like suggested sticking an if condition inside of save_char() and do_save() I have made it so that levels less than 5 no longer save.
Now for my next question. I wanted to make it so that if a player is less than level 5 during a copyover, it would advance them to level 5 to allow them to save. This is what I wrote.
if (och->level < 5)
{
int l = och->level;
write_to_descriptor (d->descriptor,
"Since you below level 5, you will be advanced!\n\r", 0);
for ( ; l < 5; l++)
{
advance_level (och);
och->level++; /* Advance_level doesn't do that */
}
}

It didn't work. I am assuming that since I disabled levels less than 5 to save it is preventing the och->level from incrementing, either that or my for statement isn't accurate. Could it possibly one or the other, or both that is preventing my copyover from advancing levels less than 5 to 5?
24 Feb, 2010, jurdendurden wrote in the 5th comment:
Votes: 0
Just change the minimum level for usage in interp.c to 5.

Edit: Didn't realize you already had this issue resolved. :( But this would still be a lot easier.
24 Feb, 2010, jurdendurden wrote in the 6th comment:
Votes: 0
Maybe you could put this in do_copyover, before it goes through and saves everyone on the game:

while (och->level < 5)
{
advance_level(och);
}
24 Feb, 2010, triskaledia wrote in the 7th comment:
Votes: 0
Simply changing the level reqs for save to level 5 doesn't do anything but prevent them from typing save until level 5. Player files still save.
24 Feb, 2010, jurdendurden wrote in the 8th comment:
Votes: 0
They still autosave? That's the only way it would without them having access to the save command. But yes, ROM does have autosaving! (As the command save tells us ;P).
24 Feb, 2010, triskaledia wrote in the 9th comment:
Votes: 0
Im sure someone else in the futute will run into this same problem, and I believe it is finally resolved. Character's below level 5 no longer save after adding a check in do_save() and save_char()
*if(ch->level < 5) { stc("Players don't save until level 5", ch); return; }*
.
During copyover when you have players less than the save:
/* For each playing descriptor, save its state */
for (d = descriptor_list; d; d = d_next)
{
CHAR_DATA *och = CH (d);
d_next = d->next; /* We delete from the list , so need to save this */

if (!d->character || d->connected > CON_PLAYING)
{ /* drop those logging on */
write_to_descriptor (d->descriptor,
"\n\rSorry, we are rebooting. Come back in a few minutes.\n\r",
0);
close_socket (d); /* throw'em out */
}
else
{
//fprintf (fp, "%d %s %s\n", d->descriptor, och->name, d->host);

//#if 0 /* This is not necessary for ROM */
/***original ROM code for saving
if (och->level == 1)
{
write_to_descriptor (d->descriptor,
"Since you are level one, and level one characters do not save, you gain a free level!\n\r",
0);
advance_level (och);
och->level++; *** Advance_level doesn't do that ***
}
changed to advance the char to level 5***/
while (och->level < 5)
{
int l = och->level;
write_to_descriptor (d->descriptor,
"Since you below level 5, you will be advanced!\n\r", 0);
for ( ; l < 5; l++)
{
advance_level (och, TRUE);
och->level++; /* Advance_level doesn't do that */
}
}
//#endif
fprintf (fp, "%d %s %s\n", d->descriptor, och->name, d->host);
save_char_obj (och);

write_to_descriptor (d->descriptor, buf, 0);
}
}

So what I did was comment out the #if 0 and the //#endif, rewrote the advance the character to advance them to level five, and moved the
fprintf (fp, "%d %s %s\n", d->descriptor, och->name, d->host);

to be right before the save_char_obj so that the players would be advanced to the proper level before writing them out into a file.
24 Feb, 2010, Skol wrote in the 10th comment:
Votes: 0
Trisk… I'm surprised no one has asked, but _why_ would you not want players to be able to save from level 1-4? I personally even added more saving (with a toggle, autosave) so that characters could have the game autosave them if they improve a skill, gain level, exp etc.
25 Feb, 2010, Koron wrote in the 11th comment:
Votes: 0
Frankly, unless your playerbase is huge enough to bog the server down with massive autosaving, there's no reason to allow players to turn it off. If someone discovers how to crash your mud, they can set up a good scheme whereby they config -autosave and give a rare uberpowerful item to their +autosave friend, then crash the mud.

Even if it's not a deliberate exploit, how do you prove that someone didn't just pick up a sword of +10 awesomeness right before a crash?

That said, I think this is the best approach:
jurdendurden said:
Maybe you could put this in do_copyover, before it goes through and saves everyone on the game:

while (och->level < 5)
{
advance_level(och);
}
25 Feb, 2010, jurdendurden wrote in the 12th comment:
Votes: 0
So the advance_level func doesn't increment the actual level of the char?? That's gotta be a major oversight.

Edit: looks like do_advance in act_wiz.c does though.
25 Feb, 2010, jurdendurden wrote in the 13th comment:
Votes: 0
Ahh after looking briefly it appears that advance_level only handles the gains/pracs/trains of the char, not the actual level, gain_exp does.
28 Feb, 2010, triskaledia wrote in the 14th comment:
Votes: 0
The reason for me not wanting the players to save is simple enough. I have a plist command, and when I use it, I don't want to see a spam of characters that won't ever be coming back. Most people log, look, and quit. Don't bother leveling, talking, asking questions, etc. I have no need to have them saved.
As for the uberpowerful thing… I don't have a config -autosave. Autosave is as it is, automatic. Exception for players less than 5, where they no longer save for the above reasons.
28 Feb, 2010, Scandum wrote in the 15th comment:
Votes: 0
triskaledia said:
So, what I'm asking is if anyone knows how to prevent those players from saving
at all.
Any help appreciated.

What you want instead is a purger that deletes players that you're no longer interested in, like players with a level below 5 that haven't logged in for over a month, or players below 10 that haven't logged in for 2 months. I'd advice against purging high level players as some tend to come back, sometimes after several years. You can check out purger.c in the emud 3.0 codebase if you're looking for examples.
28 Feb, 2010, triskaledia wrote in the 16th comment:
Votes: 0
Where can I find a link to emud 3.0 ?
28 Feb, 2010, Kline wrote in the 17th comment:
Votes: 0
[link=file]688[/link]
0.0/17