Item Durability

  • Papaya Pete
  • Papaya Pete's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
5 years 1 day ago #2453 by Papaya Pete
Papaya Pete replied the topic: Item Durability
So I put in a special procedure one can add to shopkeepers to make them be able to repair items. So far, I just have armor and weapons being the only things that can be repaired... though thinking about it, you can add wear and tear for most things. Containers, for example, might have a check that is run to see if it is almost full. If so, that can reduce the condition. Notes can experience wear and tear as well whenever they're read. I don't think I'll try to do those things, though.

So it looks like this snippet is done! I just need to test a couple things out and then finish putting the instructions together.

On a side note though.... I did find a bug that causes the mud to crash, at least if you happen to be using CYGWIN. It occurs when you have two characters that are separated by doors, and one of them opens that door. Here is the result of the backtrace... that's all I put this time because I don't think it's something I can deal with... but any ideas on how to resolve this would be much appreciated.
#0  strlen ()
    at /usr/src/debug/cygwin-1.7.18-1/newlib/libc/machine/i386/strlen.S:38
#1  0x75381194 in WaitForSingleObjectEx ()
   from /cygdrive/c/Windows/syswow64/kernel32.dll
#2  0x75381148 in WaitForSingleObject ()
   from /cygdrive/c/Windows/syswow64/kernel32.dll
#3  0x610dd558 in sig_send (p=<optimized out>, si=..., tls=0x271318)
    at /usr/src/debug/cygwin-1.7.18-1/winsup/cygwin/sigproc.cc:682
#4  0x610303b4 in exception::handle (e=0x2715ec, frame=0x28ff14, in=0x27163c)
    at /usr/src/debug/cygwin-1.7.18-1/winsup/cygwin/exceptions.cc:644
#5  0x7776b459 in ntdll!LdrRemoveLoadAsDataTable ()
   from /cygdrive/c/Windows/system32/ntdll.dll
#6  0x002715ec in ?? ()
#7  0x7776b42b in ntdll!LdrRemoveLoadAsDataTable ()
   from /cygdrive/c/Windows/system32/ntdll.dll
#8  0x002715ec in ?? ()
#9  0x77720133 in ntdll!KiUserExceptionDispatcher ()
   from /cygdrive/c/Windows/system32/ntdll.dll
#10 0x002715ec in ?? ()
#11 0x61164487 in _svfprintf_r (data=0x28d41c, fp=0x271be0,
    fmt0=0x50b99c <wld_cmd_info+892> "The %s is %s%s from the other side.\r\n", ap=0x271cf0 "")
    at /usr/src/debug/cygwin-1.7.18-1/newlib/libc/stdio/vfprintf.c:1527
#12 0x6113a2d5 in _vsnprintf_r (ptr=0x28d41c,
    str=0x60b860 <txt.8440> "The \020\037'", size=49152,
    fmt=0x50b99c <wld_cmd_info+892> "The %s is %s%s from the other side.\r\n",
    ap=0x271ce8 "x\034'")
    at /usr/src/debug/cygwin-1.7.18-1/newlib/libc/stdio/vsnprintf.c:66
#13 0x6113a345 in vsnprintf (str=0x60b860 <txt.8440> "The \020\037'",
    size=49152,
    fmt=0x50b99c <wld_cmd_info+892> "The %s is %s%s from the other side.\r\n",
    ap=0x271ce8 "x\034'")
    at /usr/src/debug/cygwin-1.7.18-1/newlib/libc/stdio/vsnprintf.c:41
#14 0x610d75e5 in _sigfe () from /usr/bin/cygwin1.dll
#15 0x0050b99c in wld_cmd_info ()
#16 0x00271ce8 in ?? ()
#17 0x004f9d5f in write_to_output (t=0x80f0c520,
    txt=0x50b99c <wld_cmd_info+892> "The %s is %s%s from the other side.\r\n")
    at comm.c:1270
#18 0x004fa499 in send_to_room (room=638,
    messg=0x50b99c <wld_cmd_info+892> "The %s is %s%s from the other side.\r\n") at comm.c:2430
#19 0x00402d08 in do_doorcmd (ch=<optimized out>, obj=<optimized out>, door=1,
    scmd=1) at act.movement.c:586
#20 0x0040429d in do_gen_door (ch=0x80f14ad0, argument=0x28a932 "east",
    cmd=465, subcmd=1) at act.movement.c:675

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

More
5 years 1 day ago #2460 by Rumble
Rumble replied the topic: Item Durability
Tried reproducing the door crash without any luck. Feel free to stop by TBA to see if we can reproduce.

Rumble
The Builder Academy
tbamud.com 9091

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

  • Papaya Pete
  • Papaya Pete's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
5 years 21 hours ago - 5 years 21 hours ago #2472 by Papaya Pete
Papaya Pete replied the topic: Item Durability
Well this is very interesting! I managed to replicate it; when the key to an exit is set to 0, that's when the crash occurs. Here is another strange thing that's going on though; when you open or close a door, this is what you see on the other side.
close east
Okay.

(Other person sees this)
The P' is (null)(null) from the other side.

This notifying the other room is found in the do_doorcmd function in act.movement.c, at the end.

This just might be a problem with CYGWIN though. I remember trying to use Vatiken's crafting snippet and it not working for some strange reason (even though the same thing worked for everyone else). It's making me seriously consider ditching CYGWIN for something else, though I don't have a free box to try and install (and learn) linux atm....

Edit: a combo of Windows 7 and CYGWIN actually, since I remember the former having issues with running older problems.

Also, looking at the entire function, it looks like part of the problem is that the pointer *back is initialized at NULL but is then never defined. Maybe I was being too harsh on windows and cywgin. Hehe (you can tell I edited this post a couple times). I'll take another look sometime tomorrow.
static void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd)
{
  char buf[MAX_STRING_LENGTH];
  size_t len;
  room_rnum other_room = NOWHERE;
  struct room_direction_data *back = NULL;

  if (!door_mtrigger(ch, scmd, door))
    return;

  if (!door_wtrigger(ch, scmd, door))
    return;

  len = snprintf(buf, sizeof(buf), "$n %ss ", cmd_door[scmd]);
  if (!obj && ((other_room = EXIT(ch, door)->to_room) != NOWHERE))
    if ((back = world[other_room].dir_option[rev_dir[door]]) != NULL)
      if (back->to_room != IN_ROOM(ch))
        back = NULL;

  switch (scmd) {
  case SCMD_OPEN:
    OPEN_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      OPEN_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "%s", CONFIG_OK);
    break;

  case SCMD_CLOSE:
    CLOSE_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      CLOSE_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "%s", CONFIG_OK);
    break;

  case SCMD_LOCK:
    LOCK_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      LOCK_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "*Click*\r\n");
    break;

  case SCMD_UNLOCK:
    UNLOCK_DOOR(IN_ROOM(ch), obj, door);
    if (back)
      UNLOCK_DOOR(other_room, obj, rev_dir[door]);
    send_to_char(ch, "*Click*\r\n");
    break;

  case SCMD_PICK:
    TOGGLE_LOCK(IN_ROOM(ch), obj, door);
    if (back)
      TOGGLE_LOCK(other_room, obj, rev_dir[door]);
    send_to_char(ch, "The lock quickly yields to your skills.\r\n");
    len = strlcpy(buf, "$n skillfully picks the lock on ", sizeof(buf));
    break;
  }

  /* Notify the room. */
  if (len < sizeof(buf))
    snprintf(buf + len, sizeof(buf) - len, "%s%s.",
      obj ? "" : "the ", obj ? "$p" : EXIT(ch, door)->keyword ? "$F" : "door");
  if (!obj || IN_ROOM(obj) != NOWHERE)
    act(buf, FALSE, ch, obj, obj ? 0 : EXIT(ch, door)->keyword, TO_ROOM);

  /* Notify the other room */
  if (back && (scmd == SCMD_OPEN || scmd == SCMD_CLOSE))
      send_to_room(EXIT(ch, door)->to_room, "The %s is %s%s from the other side.\r\n",
        back->keyword ? fname(back->keyword) : "door", cmd_door[scmd],
        scmd == SCMD_CLOSE ? "d" : "ed");
}
Last Edit: 5 years 21 hours ago by Papaya Pete. Reason: Looked at the problem a bit more.

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

  • Papaya Pete
  • Papaya Pete's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
5 years 12 hours ago #2491 by Papaya Pete
Papaya Pete replied the topic: Item Durability
So I've taken a closer look... and *back is defined early on in the function. It's done in an if statement...
len = snprintf(buf, sizeof(buf), "$n %ss ", cmd_door[scmd]);
  if (!obj && ((other_room = EXIT(ch, door)->to_room) != NOWHERE))
    if ((back = world[other_room].dir_option[rev_dir[door]]) != NULL)
      if (back->to_room != IN_ROOM(ch))
        back = NULL;

I did some checking, and threw in some send_to_char to see if those values are getting filled. Sure enough, they are.
/* Notify the other room */
  send_to_char(ch, "Value of back->keyword is %s\n", back->keyword);
  send_to_char(ch, "If that's the case, then fname(back->keyword) should be %s\n", fname(back->keyword));
  if (back && (scmd == SCMD_OPEN || scmd == SCMD_CLOSE))
      send_to_room(EXIT(ch, door)->to_room, "The %s is %s%s from the other side.\r\n",
        back->keyword ? fname(back->keyword) : "door", cmd_door[scmd],
        scmd == SCMD_CLOSE ? "d" : "ed");

For some reason, everything comes up as NULL, which is very puzzling. I'm going to take back taking back what I said; cygwin has issues. How would values that were previously defined suddenly be NULLed? And on top of that, I'm assuming that this isn't happening to everyone else.

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

More
5 years 8 hours ago #2497 by thomas
thomas replied the topic: Item Durability
I've been using cygwin on windows 7 for years without issue. I suggest you try updating (just run setup.exe again) and delete your config.* files, and then ./configure it again to see if you've got some faulty lib linked in...

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

  • Vatiken
  • Vatiken's Avatar
  • Offline
  • Administrator
  • Administrator
  • tbaMUD Programmer
More
5 years 8 hours ago #2499 by Vatiken
Vatiken replied the topic: Item Durability
In the past I had used my Windows PC as my development port prior to uploading to my linux server and did deal with several occurrences where "crash bugs" would arise on my windows port that did not appear on my development server. I now do all my Mud Development on my own linux box before uploading to my linux server, and I also use linux for every other aspect of computing and no longer own Windows.

Whatever you choose to do is up to use is up to you, everyone has a preference. The only reason I am spending time writing this is because: A) You don't need another box to run a version of linux on your computer and B) In many cases Linux is easier and more user-friendly then Windows. My wife who is NOT computer literate uses Ubuntu and refuses to touch Windows. So if those are your only reasons from not sampling a linux OS, they are not quality reasons.

FYI, you can download a copy of Ubuntu and run it off a CD or USB without installing it just to check it out.

tbaMUD developer/programmer

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

  • Papaya Pete
  • Papaya Pete's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
5 years 6 hours ago #2501 by Papaya Pete
Papaya Pete replied the topic: Item Durability
I'll try reinstalling Cygwin again and see if it is just something faulty. But if that doesn't work... hmmm. I guess I stayed away from linux for so long because I hardly know anything about it. A friend of mine gave me the impression that I'd have a very difficult time figuring out how to do things on it. Perhaps it's time I actually look into it myself and find out if that's really the case.

Ubuntu, huh? Hmmm. Yeah, I'll take a look at that and see how it goes. I just have this laptop and want to keep windows 7 on it, but it would be cool to be able to run ubuntu or something else off of it as well.

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

More
5 years 4 hours ago #2505 by Rumble
Rumble replied the topic: Item Durability
Ubuntu installs cleanly in Windows now (does its own drive-partitioning with dual boot option). I was impressed when I tried it out for a few months. But, I went back to Windows when I bought my new laptop and haven't set it back up yet.

Rumble
The Builder Academy
tbamud.com 9091

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

  • Papaya Pete
  • Papaya Pete's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
4 years 11 months ago #2533 by Papaya Pete
Papaya Pete replied the topic: Item Durability
Oh yeah, I almost forgot to do this after all that work!

Uploaded the item durability snippet. Throw a post here or something if it doesn't work right (and double-check the instructions to make sure you did them right!). :)

Thank you for your patience and help in getting this done!

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

More
4 years 11 months ago #2538 by Rumble
Rumble replied the topic: Item Durability
Thanks for sharing.

Rumble
The Builder Academy
tbamud.com 9091

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

More
4 years 1 month ago - 4 years 1 month ago #4770 by bakarus
bakarus replied the topic: Item Durability
I added everything from the snippet, and am getting an error on compile,
gcc -g -O2 -Wall    -c -o act.comm.o act.comm.c
gcc -g -O2 -Wall    -c -o act.informative.o act.informative.c
act.informative.c: In function ‘show_obj_to_char’:
act.informative.c:122: error: called object ‘obj->obj_flags.durability’ is not a function
act.informative.c:123: error: called object ‘obj->obj_flags.durability’ is not a function
act.informative.c:145: error: called object ‘obj->obj_flags.durability’ is not a function
act.informative.c:146: error: called object ‘obj->obj_flags.durability’ is not a function
make[1]: *** [act.informative.o] Error 1

checked structs.h and the line is there for int durability;

not sure what else could be wrong, here are the lines, line 122 is the first line,
if ((GET_OBJ_MAX_DURAB(obj) != 0) && (GET_OBJ_MAX_DURAB(obj) > GET_OBJ_DURABILITY(obj)))
        percent = (100 * GET_OBJ_DURABILITY(obj)) / GET_OBJ_MAX_DURAB(obj);
    else
        percent = 100;
Last Edit: 4 years 1 month ago by bakarus.

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

More
4 years 1 month ago #4771 by thomas
thomas replied the topic: Item Durability
how does the GET_OBJ_MAX_DURAB macro look like?

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

More
4 years 1 month ago #4772 by bakarus
bakarus replied the topic: Item Durability
I believe it is
#define GET_OBJ_MAX_DURAB(obj)	((obj)->obj_flags.max_durab)

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

More
4 years 1 month ago #4773 by thomas
thomas replied the topic: Item Durability
sorry - meant GET_OBJ_DURABILITY - apparently it's not got the (obj) suffix in the definition.
This means the preprocessor will substitute it as

obj->obj_flags.durability(obj)
The following user(s) said Thank You: bakarus

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

More
4 years 1 month ago #4774 by bakarus
bakarus replied the topic: Item Durability
You were exactly right, I was missing the (obj) on the macro
GET_OBJECT_DURABILITY  (obj->obj_flags.durability)

missing the (obj) after, shoulda been
GET_OBJECT_DURABILITY(obj) (obj->obj_flags.durability)

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

Time to create page: 1.889 seconds