Commit Graph

767 Commits

Author SHA1 Message Date
dongresource 34bd7c102f Validate emails as they're being sent 2021-01-06 14:30:25 +01:00
CakeLancelot 9e30e55669 eggBuffPlayer now takes duration, and buff duration is read from EggType 2021-01-06 05:56:54 -06:00
dongresource 46b6d9fcc7 Include CNStructs.hpp in settings.cpp for the ACADEMY define
This fixes the spawn point being wrong.
2021-01-06 12:30:33 +01:00
Jade 2bf3fd0975 Further sanity checks for shops 2021-01-06 11:47:07 +01:00
dongresource 442f85c7a6 Make paths.json academy-specific 2021-01-05 14:07:41 +01:00
dongresource b87229aa65 Reject requests to equip items into the wrong slot
This is important because the client can genuinely send such an invalid
packet by mistake during normal gameplay.

If a sanity check fails, we don't need to send any sort of "move it but
keep it where it is" packet, since simply ignoring the invalid request
doesn't softlock the client.

Also improved validation of inventory slot indexes.
2021-01-05 13:17:59 +01:00
dongresource deca220d43 Do not auto-register all fast travel destinations for GMs
Instead, players with access level 50 or higher can use /registerall and
/unregisterall.
2021-01-05 12:44:38 +01:00
Jade 74e06f1084 Trading Refactor
- Its no longer possible to dupe items by stacking inventory slots in a trade.
- Stacked items work correctly now.
2021-01-04 23:57:50 +01:00
Jade ddc7caf959 Basic Anti rapidfire 2021-01-04 23:57:50 +01:00
Jade 6baa0c5b07 Group related fixes
- Group adding is not leader only now
- Group buffs work now
2021-01-04 23:57:50 +01:00
Jade d4eaf83354 Fixed Instancing Bugs 2021-01-04 23:53:44 +01:00
Jade 47d13ce39e Fixed Group Mob Retreat 2021-01-04 23:53:38 +01:00
Jade 2b95bc660c Fixed Quest Item Bug 2021-01-04 23:52:15 +01:00
dongresource 0e3fac4d34 Updated tdata and changed how the default JSON paths are resolved 2021-01-04 17:08:44 +01:00
dongresource 4516227a7b Fix a few GM issues
* Invert access check when kicking players
* Add validation to ensure only GMs can PVP
* Account for instance in /teleport2me
2021-01-01 21:38:03 +01:00
Gent S 954cfabde5 Add ID gaps for missing NPCs in Academy 2020-12-31 11:26:17 -05:00
dongresource 966bd3edd2 Group members share the same mob drops
This includes quest items.
2020-12-31 14:13:14 +01:00
dongresource dab204ddaf If compiled for Academy, do not spawn NPCs in the Future zone 2020-12-31 14:13:08 +01:00
dongresource bad8ef1d10 Kill players that fall out of the map 2020-12-31 12:51:36 +01:00
dongresource a12acbb68f Implement most of the remaining client-side GM commands
* Muting a player's freechat
* Kicking players
* Querying info about a player
* Teleporting yourself to a player
* Teleporting a player to yourself
* Teleporting a player to another player
* Teleporting a player to arbitrary coords
* Teleporting a player to arbitrary coords in an arbitrary mapnum
* /unstick

Also:
* Renamed misleading setSpecialPlayer() to setValuePlayer()
* Revamped monitor logic
* Added server-side checks to account level 50 commands
* Made sure even trade chat is run through sanitizeText()
* Moved setSpecialState() closer to its calling functions
* Interpret client commands even in Buddy and Group chat (but not in
Trade chat)
2020-12-31 12:51:31 +01:00
dongresource c78b3ca69f Do not cancel the ongoing race on recall
Also do not remove the player's vehicle if the player isn't on a
vehicle.
2020-12-31 03:00:54 +01:00
dongresource 55431362a7 Make sure the current race is cleared when leaving an IZ 2020-12-28 18:40:26 +01:00
dongresource 07a930fe1c Fix vehicles in IZs for real this time 2020-12-28 18:40:26 +01:00
dongresource 4060bf25b0 Fix recall removing FM pods if racing 2020-12-28 16:55:13 +01:00
dongresource 9a79ab3927 Reduce mob range when racing as if the player were sneaking 2020-12-28 16:41:29 +01:00
dongresource fc45775666 Add /unwarpable command
GMs should use this before going to weird places where their non-GM
buddies might warp to them and get stuck.
2020-12-28 16:24:24 +01:00
dongresource 81d0964971 Disallow warping to players using the MSS 2020-12-28 16:13:38 +01:00
dongresource 868dc8485e Allow GMs to enter private instances 2020-12-28 16:12:57 +01:00
dongresource 26f4767082 Add additional validation to the recall power 2020-12-28 16:12:23 +01:00
dongresource d97444cca5 Remove each group member's vehicle when warping into an instance 2020-12-28 00:50:58 +01:00
dongresource ee978e8bc9 Limit group member drops based on proximity 2020-12-27 21:14:16 +01:00
Gent S bdf283ae4f Make heal nanos heal for the correct amount 2020-12-27 09:23:43 -05:00
Jade f8129b91cb Zero both players' moneyInTrade when initiating a trade 2020-12-26 20:13:23 +01:00
dongresource afea9f436f Check if otherPlr is null in nanoRecallHandler() 2020-12-26 20:09:33 +01:00
dongresource 7985fc475b Fix regression with spawning in an invalid Nano #37 2020-12-24 07:41:22 +01:00
dongresource 959a708176 Return to the overworld instance when warping to a buddy 2020-12-24 06:05:05 +01:00
dongresource 44fbb8e81f Fix other group members not respawning properly in Lairs 2020-12-24 05:22:46 +01:00
Gent S 7fe0e19bb0 Fix IZ races rewarding invalid items 2020-12-23 18:31:42 -05:00
Gent S 82d5455da6 Ignore race rewards for EPs that aren't found 2020-12-23 14:53:56 -05:00
Gent S 52389c2c69 Make code redemption case-insensitive 2020-12-23 13:50:12 -05:00
Gent S ae75324153 Fix duplicate tasks on instanced mission failure 2020-12-23 13:50:12 -05:00
Gent S a1a5815f1f Fix academy nano missions not going into the 0th slot 2020-12-23 13:50:12 -05:00
Gent S 772f80188e Prevent duplicate running tasks from loading into the Player struct 2020-12-23 13:50:12 -05:00
kamilprzyb f28c643b48 Allow permanent vehicles 2020-12-23 13:50:12 -05:00
Kamil 5f82658c8d adjusted item codes logic to handle multiple items per code 2020-12-23 13:50:12 -05:00
Jade 50b2bdcb16 Fixed Nano Style Issues 2020-12-23 13:50:12 -05:00
Kamil 34dbb59fb1 Implement redeem codes 2020-12-23 13:50:12 -05:00
Kamil a74c9be2ff Implement Nano capsules 2020-12-23 13:50:12 -05:00
dongresource fcdea2e723 Implement multiple-choice mission rewards 2020-12-23 13:50:12 -05:00
dongresource 90191fd494 Add academy.json loading to TableData
This is where the permanent Academy-exclusive NPCs and mobs will be
loaded from. Resurrect 'Ems work now.
2020-12-23 13:50:12 -05:00
Gent S effbbd9a5e Fix level-up not triggering and using wrong packets 2020-12-23 13:50:12 -05:00
dongresource bc7f4883a2 Add Academy defaults to the config file 2020-12-23 13:50:12 -05:00
dongresource e0808ffcbd Read the NPC ID limit from the XDT 2020-12-23 13:50:12 -05:00
dongresource 9057f31bff Implement Academy level-up 2020-12-23 13:50:12 -05:00
dongresource 0a9f637123 Do not give the Lightning Gun and Buttercup Nano to new Academy players
And do not mark the two missions from the old Tutorial as completed.
2020-12-23 13:50:12 -05:00
dongresource 027f513a23 Save Academy Nanos to DB 2020-12-23 13:50:12 -05:00
dongresource a99f95d15f Initial Academy support
Support for the Academy's Nano system is complete, but they're not being
saved to the DB yet.
2020-12-23 13:50:12 -05:00
Jade 0104bc9329 Enemy ability tweaks
- Battery drain does not set your battery below 0.
- Debuffs cast by enemies take into account intensity now. (Snare will work)
- Used int_max to replace arbitrary 20000, added more comments.
2020-12-22 12:12:02 -05:00
Jade 4fc5c092f8 Attack logic and various balance changes
- combatStep was altered, the mob can attack and give chase at the same time. Kiting melee mobs around is much harder.
- Mobs in general are more harder, closer to how it was in retro.
- Nanos styles are less detrimental to battle.
2020-12-22 11:30:57 -05:00
Jade 8d1bc94b7e Mission Handling Fixes
- Q. Item count glitches are dealt with
- Warping out now correctly rewinds missions.
2020-12-22 11:30:57 -05:00
dongresource 322e354f5b Fix indentation in RacingManager.cpp and compilation on Linux 2020-12-22 14:46:09 +01:00
Gent S 8a2073d081 Fix racing timestamps 2020-12-22 01:04:46 -05:00
Gent S e915c54ed0 Correctly set time limit, rank, and reward 2020-12-22 00:37:04 -05:00
Gent S e953b51229 Add reward tables for racing 2020-12-22 00:36:39 -05:00
Gent S b9013149f3 Racing cleanup 2020-12-21 21:02:19 -05:00
Gent S e6da454c73 Finish racing DB integration 2020-12-21 16:18:08 -05:00
Gent S 598c7ce1d0 Add racing-related DB functions 2020-12-21 16:18:08 -05:00
Gent S ea47f67b2b Properly utilize instance data in map info packet 2020-12-21 16:18:08 -05:00
Gent S 91ea8be72e Implement basic race handling 2020-12-21 16:18:08 -05:00
Gent S b81a3761b6 Load instance data from XDT 2020-12-21 16:18:08 -05:00
Gent S 45b8f8f581 Add RacingManager 2020-12-21 16:18:08 -05:00
dongresource c3d9883ddb Fix migration on Linux 2020-12-20 23:09:10 +01:00
Gent S ea12ec9607 Use binary streams to make DB backups, since filesystem has low compat 2020-12-20 15:52:34 -05:00
Gent S 2e173df2ca DB v2 Tweaks 2020-12-19 21:17:07 -05:00
Kamil 1fb48536c2 created external sql file for tables and 1st migration 2020-12-19 20:00:47 -05:00
Kamil 002bfffb62 implemented db migration system 2020-12-19 19:15:14 -05:00
Kamil 140227406c implemented custom error messages in login screen for regex fail or banned account 2020-12-19 19:15:14 -05:00
dongresource 26d0623d07 Fix Database::sendEmail()
* Do not define an sqlite_stmt* named stmt in a loop such that it shadows
an outer variable of the same name.
* Do not re-prepare a statement that has been reset.
2020-12-19 05:51:06 +01:00
dongresource f8a359dfe9 Do not truncate emails to 127 characters
And assert that we never supply a string long enough for
sanitizeText() to truncate.
2020-12-19 05:51:06 +01:00
Gent S 2f44243abb Please.... please take the slider.... 2020-12-18 20:48:09 -05:00
dongresource e3561e9d15 Change the default ports to match OG and Retro
The default monitor port can stay on 8003 for now.
2020-12-18 00:24:24 +01:00
dongresource 80dabf4406 Finalize ALL the statements
* Fixed not being able to modify the DB externally while the script is
running
* Made most DB-related errors print the appropriate error string
* Fixed the settings looking for dbsaveinterval in the shard category
instead of the login category
* Added -shr and -wal to .gitignore (even though we're not actually
using WAL mode)

Hopefully the DB code is now free of resource leaks and undefined
behaviour.
2020-12-18 00:17:35 +01:00
Gent S d3e5b9c485 Potentially fix slider collisions
- Lerp circuit once instead of on a per-slider basis to avoid FPE differences
- Spawn sliders every k points instead of once per stop
2020-12-16 20:37:12 -05:00
dongresource f7a6615379 Tweak mob roaming logic and a few other values
This fixes the crash with mobs with a very small m_iIdleRange and avoids
unnecessary looping.

Co-authored-by: JadeShrineMaiden <69916714+JadeShrineMaiden@users.noreply.github.com>
2020-12-17 02:35:55 +01:00
Gent S 618a8d0a9f Reimplement NPC barking 2020-12-15 19:16:05 -05:00
dongresource d25e7ca4fc Implement rudimentary NPC scripting framework and Lord Fuse boss fight 2020-12-15 23:19:29 +01:00
dongresource 3359ca0c3e Moved common NPC summoning logic into a helper function 2020-12-15 23:19:29 +01:00
dongresource 0dd478b9f0 Tweak Lair respawns slightly
* Respawn the player in the air, not on the ground
* Do save the player's current instance, just to lessen the chance of
validation not catching stale recall coords.
2020-12-15 23:19:29 +01:00
Gent S d03c4f109f Add chat dump to monitor 2020-12-15 09:58:11 -05:00
Gent S 792a317b48 Indicate high account level in logged player name 2020-12-15 09:53:45 -05:00
dongresource f74c40cf69 Prevent division by zero by also checking iWalkSpeed for 0 2020-12-15 02:11:18 +01:00
dongresource 442d7853a5 In the absence of a Resurrect 'Em in a Lair, respawn at the entrance 2020-12-15 00:26:29 +01:00
dongresource fcd9b55ea7 Clean up formatting in Database.cpp
* Single quotes for strings
* Semicolons at the end of all commands
* No double colons around identifiers
* Spaces for alignment
* Some parts indented for readability

Not everything is perfectly consistent, but it should all be pretty
readable now.

Non-SQL changes:
* Opening braces shouldn't be on their own line
* Removed trailing spaces
* exit(1) should be used instead of terminate(0) during server init
2020-12-14 22:41:28 +01:00
Gent S f1a2723274 Don't write mob HP to gruntwork 2020-12-14 10:00:07 -05:00
Gent S 5431d21d27 Always grab mob HP from XDT 2020-12-14 00:26:17 -05:00
dongresource 454e0284af Remove vendored libsqlite from the repository
We now link to the system's library.

Windows implementation pending. MSVC build will be broken for a short
while.
2020-12-14 03:44:58 +01:00
Gent S 94b7864b02 Shut up warnings 2020-12-13 20:52:59 -05:00
Gent S 166bfdfc4f Terminate if existing DB doesn't have meta table 2020-12-13 20:43:24 -05:00
Gent S 156e9bf902 Fix newline characters being stripped from emails 2020-12-13 20:18:36 -05:00
Gent S c8ff130b78 Update buddy warp to new DB 2020-12-13 19:54:09 -05:00
Gent S ec23e72215 Notify client of email send failure 2020-12-13 19:51:31 -05:00
Gent S a1274756ce Fix guide not getting updated in new DB 2020-12-13 19:51:09 -05:00
Kamil 05f4746af4 "Created" meta column + cleanup 2020-12-13 19:51:09 -05:00
Kamil 04112377ea Implement setting for disabling first use tips 2020-12-13 19:51:09 -05:00
Kamil bd3a91e530 Properly implement first use flags 2020-12-13 19:51:09 -05:00
Kamil 66ecc45fce Change SkyWayFlags to blob for consistency 2020-12-13 19:51:09 -05:00
Kamil 7aef973ef1 Add meta table to DB 2020-12-13 19:51:09 -05:00
Kamil a12faac0e2 Account level changes
tied account levels to accounts instead of players. implemented account banning logic in db
2020-12-13 19:51:09 -05:00
Kamil 4dc48198ab Implement player blocking 2020-12-13 19:51:09 -05:00
Kamil 3e855cbdac Close DB properly 2020-12-13 19:51:09 -05:00
Kamil 889fc985c4 Reimplement the bank 2020-12-13 19:51:09 -05:00
Kamil c709d458f4 Fix iterators and query typo 2020-12-13 19:51:09 -05:00
Kamil 0e016646ef Properly implement PayZoneFlag and fix safe coord loading
implemented saving PayZoneFlag (is player in the past) and fixed saving coordinates properly with monkeys/instances
2020-12-13 19:51:09 -05:00
Kamil 960f2dd10c Adjust login server logic to new DB 2020-12-13 19:51:09 -05:00
Kamil 2bad1252d3 Small DB fixes 2020-12-13 19:51:09 -05:00
Kamil 31ac9d2e3b Reimplement DB functions 2/2
implemented getCharInfo
implemented delete character
implemented evaluateCustomName
implemented name change function
implemented getPlayer function
implemented functions for buddies
implemented emails
2020-12-13 19:51:09 -05:00
Kamil eeb3b1ee61 fixed a lot of queries 2020-12-13 19:51:09 -05:00
Kamil 4bf35e5239 added some unique constraints 2020-12-13 19:51:09 -05:00
Kamil 2f5c2a8764 Reimplement DB functions 1/2
implemented addAccount
implemented updateSelected
implemented findAccount validateCharacter isNameFree and isSlotFree
implemented getTableSize function
implemented functions for name save, character creation and finishing tutorial
2020-12-13 19:51:09 -05:00
Kamil 34ca36062c Create basic tables 2020-12-13 19:51:09 -05:00
Kamil a1062f220b Open DB from settings path 2020-12-13 19:51:09 -05:00
Kamil c2f640fd97 RIP ORM 2020-12-13 19:51:09 -05:00
actuallyamoose 143bb00ac0
Added checks to prevent buddy warping and item sending across time (#183) 2020-12-13 19:05:11 -05:00
JadeShrineMaiden b947ff65cf
Various bugfixes
- Eruption is now blocked by stun and sleep.
- Corruption should block all nano abilities.
- Buffs time out for other players
- Timed mission bugfixes (AGAIN)
- Corruption and Eruptions fire quicker.
- Heal egg ids fix
- No power nanos no longer break the system.
- Mobs should no longer restun.
- Mob ability chance calculation adjustments.
- Duration of the power's debuff is sent as iDamage instead of 0, this removes the ugly "Block" that shows up on successful hits.
- Group mob respawning bugfixes
- a bit of a cleanup
2020-12-12 17:22:22 -05:00
dongresource 1474ff10ac Slight adjustments to the poll() loop
Recheck the entry at the current index after we remove one. This isn't
strictly necessary, since the next pass will get it anyway.

Using a vector as opposed to our own realloc()'d array means indexing
beyond the size() is undefined behavior, so it's better to be safe.
2020-12-12 01:27:28 +01:00
dongresource 974941f4fa Close our end of the connection when we receive an EOF
This should/might fix the server's CPU usage spiking to 100%.
2020-12-12 01:27:13 +01:00
Gent S 2834891727 Properly output socket errors on Windows 2020-12-08 17:22:14 -05:00
dongresource ada8af0b82 Print informative error messages for socket operations
Windows implementation pending.
2020-12-08 15:23:58 -05:00
dongresource 86e0b1bc13 EINTR is not crash-worthy
This is how it should have been handled anyway. This fixes a (benign)
race condition when the server is killed, as well as gprof builds.

Also updated tdata.
2020-12-08 20:10:02 +01:00
Gent S d5409ed3f1 Replace bad continue statement with goto in monitor socket iteration 2020-12-08 14:05:34 -05:00
dongresource 811c9d4d5c Stop iterating in exitDuplicate() after having removed a player
This fixes a crash due to the invalidated iterator continuing to loop.
It should be safe to assume there's only ever one duplicate/stale player.

Also updated tdata.
2020-12-08 01:53:21 +01:00
Gent S a48fb3a8e8 Don't run nano mission logic at level 36 (fixes "Super Saiyan" bug) 2020-12-06 11:53:41 -05:00
dongresource 27f396af7e Oops, M_PI is POSIX so it isn't defined in math.h on Windows 2020-12-06 06:02:58 +01:00
dongresource 8ebabac7c0 Various bugfixes
* Fixed Nano stamina not being halved on respawn
* Reverted the default argument to terminate() change because MSVC is
undable to disambiguate the function pointer passed to sigaction()
* Fatal errors during init (like in TableData) can just call exit(1)
directly anyway (missing "OpenFusion: terminated." be damned)
* Switched to a slightly more portable syntax for getting the version
in the Makefile
* We shouldn't join the shard thread in the signal handler because the
thread the signal handler ends up running in is undefined behaviour and
we don't strictly need to join it anyway

Many of these issues were discovered on OpenBSD.
2020-12-06 05:25:23 +01:00
dongresource 02c5df5c1b Ours is not to decide the value of pi.
Ours is only to live by it.
2020-12-06 02:45:20 +01:00
dongresource dd6fbfb683 Tweak terminate() slightly
* Gave it a default argument, since we never actually care about it, but
it needs to have it to conform to the signal handler prototype
* Constricted the area locked by activeCrit to only the block that deals
with the connections vector, to lower the chance of a future badly
placed call to terminate() deadlocking the server instead
2020-12-06 02:20:46 +01:00
dongresource 92307063fc Integrate the monitor's listener socket into the shard's poll()
This removes the need for a separate monitor thread.
2020-12-06 01:44:37 +01:00
dongresource 53d8cb67ba Set monitor connections to non-blocking
Better to just drop monitor connections when the quality is bad than to
risk blocking the shard thread.
2020-12-05 23:16:09 +01:00
dongresource 6b257887b7 Use an std::vector for PollFDs instead of handling it manually
Lowered poll() timeout to 50, to fix (work around?) slider stutter.
2020-12-05 22:51:17 +01:00
dongresource ec7cba644c Clean up polling logic
* Extracted PollFD manipulation and nonblocking socket configuration
into helper functions
* Replaced the connections list with an unordered_map
* Dynamically grow the number of PollFD structures with realloc()

With these changes done, the server's CPU usage is completely diminished
from its old average of ~47% to ~0.07%, with occasional spikes up to ~14%.
2020-12-05 22:47:50 +01:00
dongresource 269315ca09 Support for poll() (ie. WSAPoll()) on Windows 2020-12-05 22:47:50 +01:00
dongresource 661061b4eb Switch to non-blocking sockets + poll(); prepare for Windows logic 2020-12-05 22:47:50 +01:00
dongresource 3a2b488f33 [WIP] fixed a million bugs and one potential one 2020-12-05 22:47:50 +01:00
dongresource 721b3f440f [WIP] Switched to poll(), but only on Unix 2020-12-05 22:47:50 +01:00
Gent S b04c377d7c Properly implement item types. 2020-12-04 16:42:58 -05:00
Gent S 794856a63c Clean up item loading from XDT. 2020-12-04 13:57:08 -05:00
Gent S 856a90abcf Fix nano logic in goo damage running without a nano out 2020-12-04 11:59:53 -05:00
dongresource 88d904e302 Fix FM patches not dealing damage unless invulnerable 2020-12-04 17:48:12 +01:00
dongresource 46552307cd Disable monitor by default in config file 2020-12-04 17:30:21 +01:00
dongresource 26024de866 Support the monitor interface on Windows as well
This change required sacrificing both code cleanliness and the specific
error reports from perror(). Those could have been kept with a portable
wrapper, but that's too much work. We'll do it if unforseen errors
arise.
2020-12-04 17:25:32 +01:00