Add unknown packet handling in Lua
Pull Request Prelude
- [x] I have followed proper The Forgotten Server code styling.
- [x] I have read and understood the contribution guidelines before making this PR.
- [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
Changes Proposed
This pull request aims to add packet handling in Lua for network messages with unknown packet types. The idea, in the long run, is to move lightweight handlers to Lua for easy extensibility, rather than baking into the source code. New packet types should be added directly with Lua scripts instead.
This is a draft and requires significant improvements.
Closes #1786
any advantage for doing this as creaturescript instead of player event?
any advantage for doing this as creaturescript instead of player event?
None at all! I am just too dumb to know the other alternatives. Appreciate the help :rofl:
here is my diff in case you need help: https://github.com/Zbizu/forgottenserver/commit/76e25ea03bed74ef3437c8893329c759993dc012
closes #1786 (if gets merged ofc)
I've been using it for a while now and it's pretty stable. Any suggestions?
https://github.com/Zbizu/forgottenserver/commit/de2db0c6135d1bf505a158e69fecc68dd65f2077#
if I remember correctly these two packets aren't handled by the code fully, but can be ignored because one situation is scripted in onLogin, the other is handled by noPongTime in vocations.xml so they make pointless calls
I've been using it for a while now and it's pretty stable. Any suggestions?
Avoid copying , if we parse only unhandled opcodes then why are we copying?
if I remember correctly these two packets aren't handled by the code fully, but can be ignored because one situation is scripted in
onLogin, the other is handled bynoPongTimein vocations.xml so they make pointless calls
Is it a big deal to just if ... then return to skip these two?
Avoid copying , if we parse only unhandled opcodes then why are we copying?
Well, because I don't want the network message to be stored for later usage only to crash the server because it was used after deletion. But maybe it would be better to move the message into parsePacket instead of passing a ref.
When I merge these changes I can't connect with any character, I think the handling of the buffers is not correct
simply trying to enter does nothing, not even the ProtocolGame::parsePacket(NetworkMessage& msg) method is executed correctly
the packets fail to copy (report shows in base64 that entire packet was 0x00)

I wasn't able to compile any previous commit on that branch
With help from @MillhioreBT I believe the issue above has been fixed. The problem was replacing memcpy with copy_n without properly converting data types, I reverted to memcpy which works as expected.
@Zbizu if you have time, please check again that it has been fixed