Top Mud Sites Forum Return to
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Thread Tools
Old 09-20-2002, 10:39 AM   #1
New Member
Join Date: Apr 2002
Posts: 14
Jaegar is on a distinguished road

I am working with Rom 2.4 and trying to figure out how to modify the existing mpedit_list function to show which mobs (if any) an mprog is set on.  I know that it will probably involve adding a new for loop (which is one of my weakest areas), if anyone would be able to give me an example of how this loop would be written I would be thankful.

Any help would be appreciated.

Thanks in advance,

Jaegar is offline   Reply With Quote
Old 09-25-2002, 01:49 PM   #2
New Member
Join Date: May 2002
Location: Kentucky
Posts: 14
Emit is on a distinguished road
Send a message via AIM to Emit
Rom 2.4 is the codebase i code on, but i can't get to the code right now to look at it.
there are several solutions to what you describe, but i'll just outline the brute force method now:
MP_DATA *pmp; /*i don't remember if this is the right var type
                               * replace MP_DATA with however you declare them
int vnum;
bool found = FALSE;
vnum = atoi(argument);

for (mob = mob_list; mob; mob = mob->next)
  for(pmp = mob->mprogs; pmp; pmp = pmp->next)
     if (vnum == pmp->vnum)
        sprintf(buf, "Mob %s\n\r", mob->name);
        send_to_char(buf, ch);
        found = TRUE;
if (!found) send_to_char("None found.\n\r", ch);
the time complexity of nested for loops like this gets pretty hairy, another way to do it is maintain a linked list of the information (you can generate it during boot_db at some point) but i only recommend that if you expect to use this function alot, and have LOTS of mprogs

--edit because i read his actual question
this code is for a command that takes an int argument, specifically the vnum your interested in.  if you want mpedit list to show the mobs a mprog is linked to, you could write this as a function like so
void show_mprog_links(CHAR_DATA *ch, int vnum);
remove the lines
int vnum;
vnum = atoi(argument);

and then call this function from inside mpedit_list
Emit is offline   Reply With Quote

Thread Tools

Modifying mpedit_list - Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying write_to_buffer Jaegar MUD Coding 6 12-01-2003 01:59 PM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 02:18 PM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud 2014