otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

OnCreatureSay out of range value error #3980

Open EPuncker opened 2 years ago

EPuncker commented 2 years ago

Before creating an issue, please ensure:

Steps to reproduce (include any configuration/script required to reproduce)

  1. Go to any shop NPC and say trade

Expected behaviour

no error

Actual behaviour

download

MillhioreBT commented 2 years ago

The problem is that now we must handle numbers carefully on the lua side, in this case we are setting a negative number and getNumber expects a number of the same type. sell = -1 I guess now we should use the number 0? I'm not sure if 0 is a valid index for lua references though, or it would also work to change the type of number we expect to int instead of uint https://github.com/otland/forgottenserver/blob/d87a01521243a4e9a94f4320d58085b1edc1337f/data/npc/lib/npcsystem/modules.lua#L819

https://github.com/otland/forgottenserver/blob/7a74c3d7383ceccc77d53d6af2d6ab5cdcc90291/src/npc.cpp#L1055-L1056

Zbizu commented 2 years ago

number 0 works fine, tested https://github.com/Zbizu/forgottenserver/commit/095a8ffb5e3e132ecef33e6a991c582f9f21d20a

there's no reason to have type different than u32 in these fields anyway

nekiro commented 1 year ago

number 0 works fine, tested Zbizu@095a8ff

there's no reason to have type different than u32 in these fields anyway

What if you want to sell item for free? Thus setting 0. and u64 is perfectly fine for money prices.