do_split adding extra coins during split

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 weeks 6 days ago - 2 weeks 6 days ago #10230 by Nero
I am noticing a wonky issue with do_split
if a member of the group splits the gold from a kill and there is 1 coin left, it is giving 2 coins to the looter
see attached screenshot

fight.c
    if (GROUP(ch) && (local_gold > 0) && !IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOSPLIT)) {
      struct obj_data *coin_obj, *next_obj;
      struct obj_data *corpse_obj = get_obj_contents_room_vis(ch, "corpse");
      if (corpse_obj) {
        do_get(ch, "all.currencie corpse", 0, 0);
        do_split(ch,local_buf,0,0);
      }
      /* need to remove the gold from the corpse */
    }
    else if (!IS_NPC(ch) && (ch != victim) && PRF_FLAGGED(ch, PRF_AUTOGOLD)) {
      do_get(ch, "all.currencie corpse", 0, 0);
    }
    if (!IS_NPC(ch) && (ch != victim) && PRF_FLAGGED(ch, PRF_AUTOLOOT)) {
      do_get(ch, "all corpse", 0, 0);
    }
    if (IS_NPC(victim) && !IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOSAC)) {
      do_sac(ch,"corpse",0,0);
    }
    return (-1);
  }
  return (dam);
}


act.other.c
    decrease_gold(ch, share * (num - 1));

    /* Abusing signed/unsigned to make sizeof work. */
    len = snprintf(buf, sizeof(buf), "%s splits %d coins; you receive %d.\r\n",
        GET_NAME(ch), amount, share);
    if (rest && len < sizeof(buf)) {
      snprintf(buf + len, sizeof(buf) - len,
        "%d coin%s %s not splitable, so %s keeps the money.\r\n", rest,
        (rest == 1) ? "" : "s", (rest == 1) ? "was" : "were", GET_NAME(ch));
    }

    while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
      if (k != ch && IN_ROOM(ch) == IN_ROOM(k) && !IS_NPC(k)) {
          increase_gold(k, share);
          send_to_char(k, "%s", buf);
            }

    send_to_char(ch, "You split %d coins among %d members -- %d coins each.\r\n",
        amount, num, share);

    if (rest) {
      send_to_char(ch, "%d coin%s %s not splitable, so you keep the money.\r\n",
        rest, (rest == 1) ? "" : "s", (rest == 1) ? "was" : "were");
      increase_gold(ch, rest);
    }
  } else {
    send_to_char(ch, "How many coins do you wish to split with your group?\r\n");
    return;
  }
}
Attachments:
Last edit: 2 weeks 6 days ago by Nero.

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

More
2 weeks 5 days ago #10231 by thomas
Replied by thomas on topic do_split adding extra coins during split
Indeed, the "increase_gold(ch, rest)" call shouldn't be there. We're already not subtracting that single coin, so this is a gold duplication bug. Well spotted!

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

More
2 weeks 5 days ago #10232 by thomas
Replied by thomas on topic do_split adding extra coins during split
Fixed and merged :)
The following user(s) said Thank You: Nero

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

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 weeks 5 days ago #10233 by Nero
Replied by Nero on topic do_split adding extra coins during split
Thanks Thomas happy to help contribute!

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

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 weeks 5 days ago #10234 by Nero
Replied by Nero on topic do_split adding extra coins during split
I had to change ours to all.currencie instead of all.gold or all.coin. One thing I was noticing was if a mob had a piece of equipment labeled gold or coin in it, it would try to loot that first before looting the gold. Not sure if there was an easier way around that but this works for us.

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

Time to create page: 0.162 seconds