Premium Intel 764 Posted October 14, 2023 Premium Share Posted October 14, 2023 So, @ Syreldar was making a quest for a server I am working on and, he noticed that after the value 255, the direction set was not working properly. For some reason, dir is an int almost everywhere, except his declaration in the struct and the two lua functions. I understand the int in the spawnmob function as a parameter, for the -1 thing to decide to make it random, but then, it should be a number between 0 and 359 but somehow they decided to go with an 8bits representation number (BYTE) So here we are fixing another korean mistake.. Go to regen.h, and replace: BYTE direction; with uint16_t direction; Go to questlua_dungeon.cpp, replace: BYTE dir = (int) lua_tonumber(L, 4); with uint16_t dir = static_cast<uint16_t>(lua_tonumber(L, 4)); both in dungeon_spawn_mob_dir_ac and dungeon_spawn_mob_dir (not needed but for consistency at this point..) Go to char_manager.cpp in: LPCHARACTER CHARACTER_MANAGER::SpawnMob(DWORD dwVnum, long lMapIndex, long x, long y, long z, bool bSpawnMotion, int iRot, bool bShow) add: if(iRot > 359){ iRot = 359; } before if (iRot == -1) iRot = number(0, 360); and that's it. 4 1 1 1 2 3 Link to comment Share on other sites More sharing options...
Active Member Koray 2014 Posted October 14, 2023 Active Member Share Posted October 14, 2023 The same issue is present within the characters, due to the rotation values in the move packets, after interaction with mount and horse, there will be synchronization issues in your movements by other individuals. Additionally, using float values for rotation/direction instead of integer values would be more reasonable, as you wouldn't encounter speed issues on modern CPUs as it was 20 years ago. Thanks for share. 1 Link to comment Share on other sites More sharing options...
Forum Moderator Gurgarath 2524 Posted October 15, 2023 Forum Moderator Share Posted October 15, 2023 Thank you for share! BYTE dir = (int) lua_tonumber(L, 4); I legit sighed. This is exactly what I said on the Discord two days ago, some types and some castings doesn't make a single sense at all. They will assign a BYTE for directions and other important stuff (causing this kind of issue or simply hard future-proof code) while casually assigning a DWORD and other way too big types for a single constant, let's say guild levels or the amount guild members 2 1 1 Gurgarath coming soon Link to comment Share on other sites More sharing options...
Premium Intel 764 Posted October 15, 2023 Author Premium Share Posted October 15, 2023 (edited) 5 hours ago, Gurgarath said: Thank you for share! BYTE dir = (int) lua_tonumber(L, 4); I legit sighed. This is exactly what I said on the Discord two days ago, some types and some castings doesn't make a single sense at all. They will assign a BYTE for directions and other important stuff (causing this kind of issue or simply hard future-proof code) while casually assigning a DWORD and other way too big types for a single constant, let's say guild levels or the amount guild members Yeah, I immediately had you and that discussion in mind when I found this lol Syreldar also showed me the directions used for the dungeons in the official. All under 255. Legit multiverses aligned for this thing to never be discovered before lmao Edited October 15, 2023 by Intel 1 Link to comment Share on other sites More sharing options...
Recommended Posts