DarkCastleMUD / DarkCastle

Dark Castle is a text-based MUD (multi-user dungeon) that was originally based on DIKU MUD around 1995. It has been running since then.
https://www.dcastle.org/
GNU Lesser General Public License v2.1
12 stars 11 forks source link

SEDIT command sets the incorrect skill #191

Closed pkoos closed 2 years ago

pkoos commented 2 years ago

example skill: release (368)

When you type sedit add it adds the incorrect skill. In this case, it adds 'release golem' (125). The reason this happens is in the find_skill_num function(), and str_n_nosp_cmp function. This searches through the given command, ending at strlen(command). If everything matches up until this point, it will return the skill number that doesn't correspond to the correct skill.

This could be OS-dependent as there is a definition flag around strncasecmp() (not sure about this).

Potential fixes:

  1. Change the order of the collections being searched. Maybe move spells below skills?
  2. Change name length <= strlen[collection[I]) to a different operator. Side effect: This will require you to type the entire command to sedit instead of just a part of the command.
jhhudso commented 2 years ago

Here's how the command works now when dealing with ambiguous input:

Z:1 R:200 I:0> sedit julian add relea Skill 'relea' is too ambiguous. Please specify one of the following: release release elemental release golem

Z:1 R:200 I:0> sedit julian add release 'Julian' has been given skill 'release' (368) by Julian.

Z:1 R:200 I:0> sedit julian remove releas Skill 'releas' is too ambiguous. Please specify one of the following: release release elemental release golem

Z:1 R:200 I:0> sedit julian remove release Skill 'release' (368) removed from Julian.

Z:1 R:200 I:0> sedit julian remove release e Cannot find skill 'release elemental' on 'Julian'.

Z:1 R:200 I:0> sedit julian add release e 'Julian' has been given skill 'release elemental' (169) by Julian.

Z:1 R:200 I:0> sedit julian set release e 1 'Julian' skill 'release elemental' set to 1 from 1.