#Wow look, it's a thread!
128 messages · Page 1 of 1 (latest)
😎
First my experience is mostly from emulating Ultima Online servers to work with offical EA clients.
Ultima Online used UDP packets that had distinct byte length patterns and a distinct ID prefix.
The server would have a listener for incoming packets. They'd be transformed from raw byte string to C# objects then pushed into a queue. (some packets had higher priorities).
A game manger would pop off the queue and made changes to the server state.
Entities within a range would receive update packets of where the piece needed to transform to.
The client does the same packet handling except it has to control the proxy puppets (actors) on the client side.
So when the character moves on the client, it sends a stream of packets of events to the server who says okay or denies it. If it okays it, the server usually sends out updates to other clients.
You can pool events serverside (think of counter-strike ticks)
today you can just have Json or Binary serialization
Proxy + Command pattern
thoughts?
That part sounds decent enough, for the player specific actions at least.
I guess for me it's other stuff in the world being simulated that I'm less confident on
Does the host simulate all the enemies and try to stream all of their position/velocity data to every other peer?
Or do the peers simulate their game state and try to somehow check if they're still in sync
I'm wondering what the bandwidth looks like in a game with a lot of enemy NPCs 😄
Seems like the approach is sending a delta snapshot of the game state at a low tick and interpolating on the client side
the host usually does all the NPC simulations
yep
and usually you only move NPCs that are in view of a player
so, each game object has a trigger.
so when it moves on the server, it broadcasts that movement to the people in view
ragdoll physics can be done client side
but you get some "different" results sometimes
So it's important to a degree to explicitly relate a set of players to a state change
depends on your item count and update flow
some games are more chatty than others
you can batch data also
Probably not as much if everyone's on the same screen most of the time
"here's a list of all entities that moved and their new locations"
right
might create more overhead than just sending them everything
and letting the client ignore stuff out of screen
also know the difference between UDP and TCP
Seems like a safe bet for getting the thing up and running in the first place
Oh yeah I'm aware 😄
optimize later
Making udp reliable will be "fun"
The thing you linked earlier touches on that I think
eh, if a client misses a NPC moved to xyz they'll get the update next time it moves
you'd be surprised on how resilient games can be when you just keep sending updates
I guess that's true, even if they come out of order
"enough" of them would be in order 
Only one way to find out
yep
you will want to give them an order
so you can ignore updates you've already done
object_a moves to 0,1 [packet 1]
object_a moves to 1,2 [packet 2]
but 2 gets there first and then 1, you want to ignore 1
Right
server side usually handles validations
"is this entity close enough to attack this entity"
if i'm mansplaning something tell me
I'm familiar with that yes but it's perfectly fine and helpful to get as much help as possible 😄
I'm anticipating client side prediction to be the most annoying thing to develop
But if I understand that correctly it's just extrapolation with correction
yep
If something was already moving this way, keep moving it that way until you get a packet that says otherwise
pretty much. People use to cheat in early Quake PVP matches by setting the network LERP value really high
and you'd see people run around corners before they were there
But it's more important for player movement/actions
Because you want the input to feel instant on the player end
still important for NPCs don't want them two stepping around
You let the client pretend they're moving around, shooting and killing things
While it's frantically asking the host if they're allowed to actually do it
ya
"hey i shot this thing at xyz from xyz"
server: yep
"hey i shot thing xyz from wpg"
server: i don't think so
It'll maybe even briefly show you shooting that thing client side and killing it but then it says uh uh and "rewinds" the state
yep
But that's I guess maybe a thing that was tripping me up too
i'm sure you've been in a really laggy server before
There is legit rollback but in this case wouldn't it just be replacing the state
ya
Overwatch servers were like 20hz tick rate on release lol...
in client land, the game manager kills entity_a
server land, denys it and sends update entity_a packet to client
client land: receive entity_a state and setup proxy for user
Not that OW was laggy, but it was plenty of time for the predictions to be wrong a lot of the time
people complain about hitregistration
that's the issue we're discussing
Which was great for those "I saw it hit you" moments where they got you first
server and client had different views of where entity_a was
Which then killed you
Making your predicted shot invalid
ya
that's another thing
if player dies server side, they're still transmitting client side
server side gotta reject those until respawn
Probably not a bad idea to have a pending deletion state that can be easily reverted if necessary and otherwise completely deleted once the server gives it the ok. Does that sound correct?
ya
Instead of having the client just delete shit and have to add it back when it fucks up
easy to just "hide" stuff
Yeah
Hide, pause tick
and if you want to be clever you can even respawn it from a spawn point
so it doesn't look rubberbandy
I think I'm not understanding that idea
player shoots and thinks they killed the entity
servers like "naw"
so now you have to call the player a lier
or if it's a npc, just spawn it back like it was killed but don't count the score
just depends on how you want to handle the mistake
i perfer gaslighting them
"sure, you did kill it"
lol I see what you mean now
Instead of it phasing back into existence
ya
good luck
👍
wow a thread
yeah
Any progress Gary?
Not in the integration yet. We've been setting up a lot of the core framework with flecs intending to use Godot only as a front end for rendering, input, UI, audio etc
I'm setting up my webrtc server with a simple lobby system
Once all of that stuff is sorted out I can actually get to the net code...
Well hurry up
private squirrel3Hash(position: number, seed: Long): number {
let n = Long.fromInt(position).multiply(0x1f1f1f1f).xor(seed);
n = n.xor(n.shiftRight(15));
n = n.multiply(n.or(Long.ONE));
n = n.xor(n.shiftRight(7));
n = n.multiply(n.or(Long.ONE));
n = n.xor(n.shiftRight(14));
return n.mod(Long.fromInt(CHARACTER_SET_LENGTH)).toNumber();
}
private generateSquirrel3Id(seed: Long): string {
// Precompute 6 character positions
const char1 = this.squirrel3Hash(0, seed);
const char2 = this.squirrel3Hash(1, seed);
const char3 = this.squirrel3Hash(2, seed);
const char4 = this.squirrel3Hash(3, seed);
const char5 = this.squirrel3Hash(4, seed);
const char6 = this.squirrel3Hash(5, seed);
// Return the 6-character string using precomputed characters
return CHARACTER_SET[char1]! + CHARACTER_SET[char2]! + CHARACTER_SET[char3]! +
CHARACTER_SET[char4]! + CHARACTER_SET[char5]! + CHARACTER_SET[char6]!;
}
public generateUniqueSimpleId(): string {
let newId: string;
do {
this.idCounter = this.idCounter.add(1);
const timestamp = Long.fromNumber(Date.now());
// Combine the 32-bit counter and the 32-bit timestamp into a 64-bit seed
const seed = this.idCounter.shiftLeft(32).or(timestamp.and(Long.fromInt(0xFFFFFFFF)));
newId = this.generateSquirrel3Id(seed);
} while (this.activeIds.has(newId) || profanity.exists(newId));
this.activeIds.add(newId);
return newId;
}
profanity.exists(newId))
doing all that work just to get "ASSHOL" out of a random generator
hmm, i didn't know about squirrel3
http://eiserloh.net/noise/SquirrelNoise5.hpp
yeah idk, there's a few choice words that would be less than funny to have pop up
start with a random swear word and just random from there
I didn't realize the algorithm ever saw updates
here's the original talk
the profanity exists thing just loops a list of regex over it
😭
I don't know shit about C sharp anymore
sounds like you need to go to an eye doctor
||so you can see sharp||
🥁
a