|
|||||||
This is a discussion on "Modifying mpedit_list" in the Top Mud Sites MUD Coding forum : 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... |
|
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our MUD community today! If you have any problems with the registration process or your account login, please contact us. If you are a registered member of the old TMS forums, please click here
|
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 14
![]() |
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 |
|
|
|
|
|
#2 |
|
New Member
|
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: [code] CHAR_DATA *mob; 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; char buf[MAX_STRING_LENGTH]; 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); return; [/quote] 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 |
|
|
|
![]() |
| 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 12:59 PM |
|
|