medit - code assistance

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago - 3 months 1 week ago #7550 by cunning
cunning created the topic: medit - code assistance
I have a unique special procedures that mimics zone load. I am trying to add it to medit just as you would in Zedit.
void medit_setup_existing(struct descriptor_data *d, int rmob_num)
{
  struct char_data *mob;

  /* Allocate a scratch mobile structure. */
  CREATE(mob, struct char_data, 1);

  copy_mobile(mob, mob_proto + rmob_num);

  OLC_MOB(d) = mob;
  OLC_ITEM_TYPE(d) = MOB_TRIGGER;
  dg_olc_script_copy(d);
  /*
   * The edited mob must not have a script.
   * It will be assigned to the updated mob later, after editing.
   */
  SCRIPT(mob) = NULL;
  OLC_MOB(d)->proto_script = NULL;
  OLC_PROC(d) = OLC_MOB(d)->mob_specials.func;
}
case MEDIT_PROC_MENU:
    switch (tolower(*arg)) {
      case 'q':
        medit_disp_menu(d);
        return;

      case 'n':
        /* New entry. */
        if (OLC_PROC(d)[0].command == '~') {
          /* first command */
          if (new_mob_proc(OLC_MOB(d), 0) && start_change_procs(d, 0)) {
            medit_spec_proc_assign(d);
            OLC_SAVE(d) = 1;
            return;
          }
        }
        write_to_output(d, "What number in the list should the new command be? : ");
        OLC_MODE(d) = MEDIT_NEW_ENTRY;
        return;
 case MEDIT_NEW_ENTRY:
    /* Get the line number and insert the new line. */
     pos = atoi(arg);
     if (isdigit(*arg) && new_mob_proc(OLC_MOB(d), pos)) {
       if (start_change_procs(d, pos))
        medit_spec_proc_assign(d);
        OLC_SAVE(d) = 1;
     } else
       medit_disp_spec_menu(d);

     return;

Genmob.c
/* Error check user input and then add new (blank) command. */
int new_mob_proc(struct char_data *mob, int pos)
{
  int subcmd = 0;
  struct spec_proc new_com;

  /* Error check to ensure users hasn't given too large an index. */
  while (mob->mob_specials.func[subcmd].command != '~')
    subcmd++;

  if (pos < 0 || pos > subcmd)
    return 0;

  /* Ok, let's add a new (blank) command. */
  new_com.command = 'N';
  add_proc_to_list(&mob->mob_specials.func, &new_com, pos);
  return 1;
}


My issue is that the minute i add a new command it crashes the game. I believe the reason to be because i impact the currently loaded mobile with that procedure. I am stuck because i want to load a copy of the procedure list, and edit it, than remove it from the mob_proto than add the updated one than update the in game mobile.

i believe that i corrupt the first memory block, which than crashes the game when the mobile goes through its live procedure calls. The line in red below should have been ch->mob_specials.func[0].func = Mob armies but as you can see it is corrupted.

Program received signal SIGSEGV, Segmentation fault.
0x000055555557ebb9 in special_procs (ch=ch@entry=0x555556f959c0, victim=victim@entry=0x0, obj=obj@entry=0x0, proc_type=proc_type@entry=3, spec_type=spec_type@entry=1,
dam=dam@entry=0x0, attacktype=0, tmp_desc=0x0) at spec_assign.c:323
323 if (spec_list[MCMD(ch, subcmd).procs].proc_type != PROC_MOB)
(gdb) back
#0 0x000055555557ebb9 in special_procs (ch=ch@entry=0x555556f959c0, victim=victim@entry=0x0, obj=obj@entry=0x0, proc_type=proc_type@entry=3, spec_type=spec_type@entry=1,
dam=dam@entry=0x0, attacktype=0, tmp_desc=0x0) at spec_assign.c:323
#1 0x00005555556c21ac in mobile_activity () at mobact.c:96
#2 0x0000555555677e45 in heartbeat (heart_pulse=179800) at comm.c:1043
#3 0x000055555567d682 in game_loop (local_mother_desc=3) at comm.c:978
#4 0x000055555556e821 in init_game (local_port=<optimized out>) at comm.c:565
#5 main (argc=<optimized out>, argv=<optimized out>) at comm.c:381


#0 0x000055555557ebb9 in special_procs (ch=ch@entry=0x555556f959c0, victim=victim@entry=0x0, obj=obj@entry=0x0, proc_type=proc_type@entry=3, spec_type=spec_type@entry=1,
dam=dam@entry=0x0, attacktype=0, tmp_desc=0x0) at spec_assign.c:323
323 if (spec_list[MCMD(ch, subcmd).procs].proc_type != PROC_MOB)
(gdb) print ch->mob_specials.func[0]
$3 = {command = 104 'h', procs = 32767, func = 0x7ffff737c068 <main_arena+1096>, freq = 1447874704, name = 0x5555564cd090 "ll.\r\n", run_type = 1, term = 0, num1 = 0, num2 = 0,
num3 = 0, num4 = 0, num5 = 0, internal = 0, line = 1, next = 0x0}

(gdb) print ch->mob_specials.func[1]
$4 = {command = 80 'P', procs = 111, func = 0x55555557b5e0 <mob_purge_pets>, freq = 100, name = 0x0, run_type = 1, term = 0, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 0, line = 2, next = 0x0}
(gdb) print ch->mob_specials.func[2]
$5 = {command = 80 'P', procs = 98, func = 0x55555557b740 <mob_unaffects_self>, freq = 100, name = 0x0, run_type = 1, term = 0, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 0, line = 3, next = 0x0}
(gdb) print ch->mob_specials.func[3]
$6 = {command = 80 'P', procs = 133, func = 0x55555557c790 <mob_heal_from_damage>, freq = 100, name = 0x0, run_type = 2, term = 1, num1 = 100, num2 = 0, num3 = 0, num4 = 0,
num5 = 0, internal = 8, line = 4, next = 0x0}
(gdb) print ch->mob_specials.func[4]
$7 = {command = 80 'P', procs = 134, func = 0x55555557c930 <mob_cap_damage>, freq = 100, name = 0x0, run_type = 2, term = 1, num1 = 100, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 6, line = 5, next = 0x0}
(gdb) print ch->mob_specials.func[5]
$8 = {command = 80 'P', procs = 106, func = 0x5555555b7050 <proc_entropy_tank>, freq = 33, name = 0x0, run_type = 1, term = 1, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 0, line = 6, next = 0x0}
Last Edit: 3 months 1 week ago by cunning. Reason: forgot a bit of code.

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #7551 by WhiskyTest
WhiskyTest replied the topic: medit - code assistance
Please excuse me if I've misunderstood, but is your end result:
To be able to add a spec_proc to a mob via medit during runtime?
(If yes then yay, I've made a patch for that!)

Or to do something tricky with multiple commands - zone reset style?

Do you mind describing the scenario in game as the player might experience it, or how you envision it working?

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago - 3 months 1 week ago #7552 by cunning
cunning replied the topic: medit - code assistance
I do both. I load and execute multiple special procs just as in Zedit. Here is a snippet of one of the mobiles.

Mob Spec-Proc: Exists, NPC Bare Hand Dam: 9d10
Spec-Proc: proc1     Prob: 100 Term: 0 SpecNum: 9/0/0/0/0
Spec-Proc: proc2     Prob: 100 Term: 0 SpecNum: 0/0/0/0/0
Spec-Proc: proc3     Prob: 70 Term: 0 SpecNum: 0/0/0/0/0
Spec-Proc: Proc4     Prob: 33 Term: 1 SpecNum: 0/0/0/0/0
Spec-Proc: proc5     Prob: 33 Term: 1 SpecNum: 0/0/0/0/0
Spec-Proc: proc6     Prob: 33 Term: 1 SpecNum: 0/0/0/0/0
Spec-Proc: proc7 Prob: 100 Term: 1 SpecNum: 60/0/0/0/0

I have NO issue loading it into Medit and displaying:

Special Procedure menu:
Procedure Freq Type Term Num1 Num2 Num3 Num4 Num4 Resist


---- ---- ---- ---- ---- ---- ---- ----
0) Proc1 100 Normal No 9 0 0 0 0 None
1) Proc2 100 Normal No 0 0 0 0 0 None
2) Proc3 70 Normal No 0 0 0 0 0 None
3) Proc4 33 Normal No 0 0 0 0 0 None
4) Proc5 33 Normal No 0 0 0 0 0 None
5) Proc6 50 Normal No 0 0 0 0 0 None
6) Proc7 100 Combat Yes 60 0 0 0 0 Magic
7 - <END OF LIST>
N) Insert new command.
E) Edit a command.
D) Delete a command.
Q) Quit


I can choose option "N" and once I choose what line to insert, the live mobile crashes the game because we have now corrupted the first spec_proc OLC_MOB(d)->mob_specials.func[0]
Last Edit: 3 months 1 week ago by cunning.

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #7560 by WhiskyTest
WhiskyTest replied the topic: medit - code assistance
OK
Not too sure about this..
Would clearing and reassigning spec_procs after your edit help?

Does it crash if the mob is not actually loaded into the game?

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago #7561 by cunning
cunning replied the topic: medit - code assistance
IF the mobile is not in the game, no it does not crash. I have even tried to copy the procs into a temp value in OLC I call OLC_PROC(d) leaving the mob_proto alone.

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago #7562 by cunning
cunning replied the topic: medit - code assistance
I was wrong, it does crash with the mob out of the game. I now get this "Error in `/development/running_game/bin/circle': corrupted size vs. prev_size: 0x00005555564cd090 ***" I think it means my array's do not match up now.

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago #7563 by cunning
cunning replied the topic: medit - code assistance
I think I may have this solved. It was my stupidity from being sick for so long with walking Pneumonia.

I was so fixated on adding OLC_MOB(d) when I should have updated a few of my procedure calls to use descriptor_data *d instead of char_data *mob. Once I did that i passed the copy of the procs through to my updated command sets. Wallah, i was now not crashing and I was much much further along.

Thanks for the assistance. Lets see if I can bring this home now :)

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago #7566 by cunning
cunning replied the topic: medit - code assistance
Now its just a PIA to get it to save out internally correct...

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #7568 by WhiskyTest
WhiskyTest replied the topic: medit - code assistance
Yay! Well done!
I was pretty lost, but sometimes its good to have a sounding board hey? :D

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago #7571 by cunning
cunning replied the topic: medit - code assistance
Well, its not been as good today. Almost all of this works, I can add new special procs to whatever line # i want. I can save it out, and it saves out correctly. However, that is where the problems begin. Anything doing with the current mob in the game or on reset crashes the game.

vstat displays the correct procs and I double checked the new mobile file and that is correct. I have the following debug. Every subcmd is correct, which is just making me SMH. I can go all the way to the last proc with no issue.

Feb 09 18:21:31 2018 :: AustinPowers: stat jupiter
Feb 09 18:21:37 2018 :: AustinPowers: vstat m 12038
Feb 09 18:21:48 2018 :: AustinPowers: zreset 120
Feb 09 18:21:48 2018 :: (GC) AustinPowers reset zone 120 (Rome)

Program received signal SIGSEGV, Segmentation fault.
0x00005555556f98bd in ?? ()
(gdb) back
#0 0x00005555556f98bd in ?? ()
#1 0x000055555557ec31 in special_procs (ch=ch@entry=0x555557203240, victim=victim@entry=0x0, obj=obj@entry=0x0, proc_type=proc_type@entry=3, spec_type=spec_type@entry=1,
dam=dam@entry=0x0, attacktype=0, tmp_desc=0x0) at spec_assign.c:332
#2 0x00005555556c20dc in mobile_activity () at mobact.c:96
#3 0x0000555555676f55 in heartbeat (heart_pulse=500) at comm.c:1043
#4 0x000055555567c792 in game_loop (local_mother_desc=3) at comm.c:978
#5 0x000055555556e841 in init_game (local_port=<optimized out>) at comm.c:565
#6 main (argc=<optimized out>, argv=<optimized out>) at comm.c:381
(gdb) up
#1 0x000055555557ec31 in special_procs (ch=ch@entry=0x555557203240, victim=victim@entry=0x0, obj=obj@entry=0x0, proc_type=proc_type@entry=3, spec_type=spec_type@entry=1,
dam=dam@entry=0x0, attacktype=0, tmp_desc=0x0) at spec_assign.c:332
332 check = (*MCMD(ch, subcmd).func)(ch, 0, strcpy(actbuf, ""), MCMD(ch, subcmd).num1, MCMD(ch, subcmd).num2, MCMD(ch, subcmd).num3, MCMD(ch, subcmd).num4, MCMD(ch, subcmd).num5, ch);
(gdb) info local
actbuf = '\000' <repeats 160 times>, "say Tick coming\r\nHey its Whirlwind/Wehr "...
check = <optimized out>
j = 0
subcmd = <optimized out>
temp = {damage = 0, attacktype = 0, resisttype = 0, attacker = 0x0}
device = {tmp_desc = 0x0, obj = 0x0}
(gdb) print ch->mob_specials.func[0]
$27 = {command = 80 'P', procs = 112, func = 0x55555557b450 <mob_armies>, freq = 100, name = 0x0, run_type = 1, term = 0, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 0, line = 1, next = 0x0}
(gdb) print ch->mob_specials.func[1]
$28 = {command = 80 'P', procs = 111, func = 0x55555557b600 <mob_purge_pets>, freq = 100, name = 0x0, run_type = 1, term = 0, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 0, line = 2, next = 0x0}
(gdb) print ch->mob_specials.func[2]
$29 = {command = 80 'P', procs = 98, func = 0x55555557b760 <mob_unaffects_self>, freq = 100, name = 0x0, run_type = 1, term = 0, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 0, line = 3, next = 0x0}
(gdb) print ch->mob_specials.func[3]
$30 = {command = 80 'P', procs = 133, func = 0x55555557c7b0 <mob_heal_from_damage>, freq = 100, name = 0x0, run_type = 2, term = 1, num1 = 100, num2 = 0, num3 = 0, num4 = 0,
num5 = 0, internal = 8, line = 4, next = 0x0}
(gdb) print ch->mob_specials.func[4]
$31 = {command = 80 'P', procs = 134, func = 0x55555557c950 <mob_cap_damage>, freq = 100, name = 0x0, run_type = 2, term = 1, num1 = 100, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 6, line = 5, next = 0x0}
(gdb)

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago #7573 by cunning
cunning replied the topic: medit - code assistance
==13791== Jump to the invalid address stated on the next line
==13791== at 0x0: ???
==13791== by 0x143AF0: special_procs (spec_assign.c:332)
==13791== by 0x286F0B: mobile_activity (mobact.c:96)
==13791== by 0x227354: heartbeat (comm.c:1043)
==13791== by 0x22CB91: game_loop (comm.c:978)
==13791== by 0x122840: init_game (comm.c:565)
==13791== by 0x122840: main (comm.c:381)
==13791== Address 0x0 is not stack'd, malloc'd or (recently) free'd

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #7574 by WhiskyTest
WhiskyTest replied the topic: medit - code assistance
What is happening in the code here: special_procs (spec_assign.c:332) ?

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #7575 by thomas
thomas replied the topic: medit - code assistance
You need a null check before the call:
if (MCMD(ch, subcmd).func != NULL)
  check = (*MCMD(ch, subcmd).func)(ch, 0, strcpy(actbuf, ""), MCMD(ch, subcmd).num1, MCMD(ch, subcmd).num2, MCMD(ch, subcmd).num3, MCMD(ch, subcmd).num4, MCMD(ch, subcmd).num5, ch);

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago #7576 by cunning
cunning replied the topic: medit - code assistance
That is one of my spec proc calls. That is telling the mobile check your list of spec procs, if your good to fire, fire away.

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
3 months 1 week ago - 3 months 1 week ago #7577 by cunning
cunning replied the topic: medit - code assistance
SOLVED!

I found that i did not provide one of my values needed.

I saw what Thomas said, and noticed that in my new command i was missing my function assignment.

$31 = {command = 80 'N', procs = 51, func = 0x0, freq = 100, name = 0x0, run_type = 2, term = 1, num1 = 100, num2 = 0, num3 = 0, num4 = 0, num5 = 0,
internal = 6, line = 5, next = 0x0}

Once i saw that i knew what to do. Slight over site on my part. Now i can edit procs on the fly and save them out. Very useful when you have 50 special procedures on a mobile.
Last Edit: 3 months 1 week ago by cunning. Reason: updated function

Please Log in or Create an account to join the conversation.

More
1 month 3 weeks ago #7766 by lacrc
lacrc replied the topic: medit - code assistance
@WhiskyTest
I know this is an old post but, since you mentioned you made a patch for this, do you have a link for it? I tried searching for it but failed miserably, sorry. :/

Please Log in or Create an account to join the conversation.

  • cunning
  • cunning's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
1 month 3 weeks ago - 1 month 3 weeks ago #7788 by cunning
cunning replied the topic: medit - code assistance
I do not have a patch for our spec procs. They are unique to JediMUD.

Now if you want to go that direction, I can certainly let you take a peak on our dev port to see what they look like. I can help and give pointers, but I would be in deep do do by the IMP and existing Admin if i gave out that code as a snippet. Though I am going to remove the object spec procs and replace with triggers in the next few weeks.

Right now the CCIE written is coming up for me and I need to recert that in a few weeks.
Last Edit: 1 month 3 weeks ago by cunning.

Please Log in or Create an account to join the conversation.

More
1 month 3 weeks ago #7796 by lacrc
lacrc replied the topic: medit - code assistance
Nah man don't worry about it!
I thought that there was something done that was public out there haha, just something that I could base off.
But no sweat, I'ma give it a go later! :)
Thanks anyway!!

Please Log in or Create an account to join the conversation.

Time to create page: 1.782 seconds