Compare commits

...

2 Commits
v0.8 ... v0.8.2

Author SHA1 Message Date
genxium
0373665382 Minor updates on ringbuffer and formatting. 2022-12-02 10:20:58 +08:00
genxium
3b0db64792 Updated README. 2022-12-01 15:46:36 +08:00
6 changed files with 8 additions and 8 deletions

View File

@@ -2,11 +2,11 @@
This project is a demo for a websocket-based rollback netcode inspired by [GGPO](https://github.com/pond3r/ggpo/blob/master/doc/README.md).
_(the following gif is sped up to ~1.5x for file size reduction, kindly note that around ~11s countdown, the attack animation is resumed from a partial progress)_
_(the following gif is sped up to ~1.33x for file size reduction, kindly note that around ~8s countdown, the attack animation is resumed from a partial progress)_
![gif_demo](./charts/melee_attack_fractional_anim_resume_spedup.gif)
![gif_demo](./charts/smooth_melee_attack_spedup.gif)
Please also checkout [this demo video](https://pan.baidu.com/s/1U1wb7KWyHorZElNWcS5HHA?pwd=30wh) to see how this demo carries out a full 60fps synchronization with the help of _batched input upsync/downsync_ for satisfying network I/O performance.
Please also checkout [this demo video](https://pan.baidu.com/s/172AmIKxbFgGXZzWVqxNUPA?pwd=e2tp) to see how this demo carries out a full 60fps synchronization with the help of _batched input upsync/downsync_ for satisfying network I/O performance.
The video mainly shows the following features.
- The backend receives inputs from frontend peers and broadcasts back for synchronization.

View File

@@ -26,7 +26,7 @@ func NewRingBuffer(n int32) *RingBuffer {
}
func (rb *RingBuffer) Put(pItem interface{}) {
for rb.Cnt >= rb.N-1 {
for 0 < rb.Cnt && rb.Cnt >= rb.N {
// Make room for the new element
rb.Pop()
}
@@ -78,7 +78,7 @@ func (rb *RingBuffer) GetByOffset(offsetFromSt int32) interface{} {
}
func (rb *RingBuffer) GetByFrameId(frameId int32) interface{} {
if frameId >= rb.EdFrameId {
if frameId >= rb.EdFrameId || frameId < rb.StFrameId {
return nil
}
return rb.GetByOffset(frameId - rb.StFrameId)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 MiB

View File

@@ -440,7 +440,7 @@
"array": [
0,
0,
216.50635094610968,
210.4441731196186,
0,
0,
0,

View File

@@ -13,7 +13,7 @@ var RingBuffer = function(capacity) {
};
RingBuffer.prototype.put = function(item) {
while (this.cnt >= this.n - 1) {
while (0 < this.cnt && this.cnt >= this.n) {
// Make room for the new element
this.pop();
}
@@ -65,7 +65,7 @@ RingBuffer.prototype.getArrIdxByOffset = function(offsetFromSt) {
};
RingBuffer.prototype.getByFrameId = function(frameId) {
if (frameId >= this.edFrameId) return null;
if (frameId >= this.edFrameId || frameId < this.stFrameId) return null;
const arrIdx = this.getArrIdxByOffset(frameId - this.stFrameId);
return (null == arrIdx ? null : this.eles[arrIdx]);
};