Skip to content

perf: network optimizations#108

Open
orangishcat wants to merge 36 commits intoaehmttw:masterfrom
orangishcat:network-optimization-cleaned
Open

perf: network optimizations#108
orangishcat wants to merge 36 commits intoaehmttw:masterfrom
orangishcat:network-optimization-cleaned

Conversation

@orangishcat
Copy link
Contributor

deletes half the codebase

  • Reflection handler to populate event fields without additional code
  • Trimmed all doubles to floats and some ints to shorts
  • Changed Game.networkRate from 60 to 20
  • Overall, reduced network traffic (upstream/downstream) by around 80%

Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
@orangishcat
Copy link
Contributor Author

Marking as draft as there are still strange interpolation issues i need to fix (will do tmrw)

Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
@orangishcat orangishcat marked this pull request as ready for review September 14, 2025 06:44
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
@orangishcat
Copy link
Contributor Author

Additional changes and stuff to test:

  • Explosions now destroy properly on client side, don't emit duplicate destroy events (thanks furret)
  • Stackable events are placed in linked hash maps to preserve stacked event order
  • Applied continuous shooting to bullets with less than 10 cooldown
  • Made bullet shoot and bullet destroy events stackable for bullets with zero cooldown
  • Added EventSetItemCount to replace EventSetItem when only the count of the item has changed
  • Made a bunch more events stackable to reduce network load
  • Added Game.recordEventData "Record event data" debug option to record network KB/s of each event every second
  • Quick actions is now sent through the network encoded as an int (thanks F6)
  • Fixed EventTankUpdateHealth to display the correct health value at all times
  • Added validation upon game launch of network events to ensure every read call is paired with a write call
  • Extracted duplicate functionality in ServerHandler and ClientHandler into NetworkHandler
  • Probably more that I forgot about

Also double check interpolation so that the tank id 0 tank isn't stuck in the corner or anything

@orangishcat orangishcat changed the title feat: network optimizations perf: network optimizations Sep 15, 2025
# Conflicts:
#	src/main/java/tanks/Game.java
#	src/main/java/tanks/hotbar/ItemBar.java
#	src/main/java/tanks/network/event/EventSetItemCount.java
#	src/main/java/tanks/network/event/EventTankUpdateHealth.java
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
@aehmttw
Copy link
Owner

aehmttw commented Dec 1, 2025

Screen Shot 2025-12-01 at 2 23 11 AM (2) the tank health is not consistent

Signed-off-by: orangishcat <fdsnail2@gmail.com>
Signed-off-by: orangishcat <fdsnail2@gmail.com>
# Conflicts:
#	src/main/java/tanks/Game.java
Signed-off-by: orangishcat <fdsnail2@gmail.com>
# Conflicts:
#	src/main/java/tanks/hotbar/ItemBar.java
#	src/main/java/tanks/network/event/EventAddNPCShopItem.java
#	src/main/java/tanks/network/event/EventAddShopItem.java
#	src/main/java/tanks/network/event/EventSortShopButtons.java
Signed-off-by: orangishcat <fdsnail2@gmail.com>
# Conflicts:
#	src/main/java/tanks/network/event/EventExplosion.java
Signed-off-by: orangishcat <fdsnail2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants