Skip to content

Commit

Permalink
Merge pull request #256 from inada-s/fix-loginkey-write
Browse files Browse the repository at this point in the history
Fix loginkey write
  • Loading branch information
inada-s authored Aug 15, 2023
2 parents 4cda37c + 41fc183 commit 78dbfbc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
16 changes: 16 additions & 0 deletions core/deps/ggpo/lib/ggpo/network/udp_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ UdpProtocol::UdpProtocol() :
_oo_packet.msg = NULL;

_send_latency = GGPOPlatform::GetConfigInt("GGPO_NETWORK_DELAY");
_jam_latency = GGPOPlatform::GetConfigInt("GGPO_NETWORK_JAM_DELAY");
_oop_percent = GGPOPlatform::GetConfigInt("GGPO_OOP_PERCENT");
}

Expand Down Expand Up @@ -822,6 +823,21 @@ UdpProtocol::PumpSendQueue()
break;
}
}

// simulate temporary packet jam
if (_jam_latency) {
if (!_enable_jam && (rand() % 600 == 0)) {
_enable_jam = true;
LogInfo("Jam!");
}
if (_enable_jam) {
if ((int)GGPOPlatform::GetCurrentTimeMS() < entry.queue_time + _jam_latency) {
break;
}
_enable_jam = false;
}
}

if (_oop_percent && !_oo_packet.msg && ((rand() % 100) < _oop_percent)) {
int delay = rand() % (_send_latency * 10 + 1000);
Log("udpproto%d | creating rogue oop (seq: %d delay: %d)", _queue, entry.msg->hdr.sequence_number, delay);
Expand Down
2 changes: 2 additions & 0 deletions core/deps/ggpo/lib/ggpo/network/udp_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class UdpProtocol : public IPollSink
uint16 _remote_magic_number;
bool _connected;
int _send_latency;
int _jam_latency;
bool _enable_jam;
int _oop_percent;
struct {
int send_time;
Expand Down
5 changes: 4 additions & 1 deletion core/gdxsv/gdxsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <random>
#include <sstream>

#include "cfg/cfg.h"
#include "cfg/option.h"
#include "emulator.h"
#include "gdx_rpc.h"
Expand Down Expand Up @@ -117,6 +116,10 @@ void Gdxsv::Reset() {
config::GdxLocalPort = get_random_port_number();
}

if (config::GdxLoginKey.get().empty()) {
config::GdxLoginKey = GenerateLoginKey();
}

NOTICE_LOG(COMMON, "gdxsv disk:%d server:%s loginkey:%s udp_port:%d", (int)disk_, config::GdxLobbyServer.get().c_str(),
config::GdxLoginKey.get().c_str(), config::GdxLocalPort.get());

Expand Down
4 changes: 3 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def run(idx, *arg_list) -> subprocess.Popen:
print(cmd)
new_env = os.environ.copy()
new_env["GGPO_NETWORK_DELAY"] = "16"
new_env["GGPO_OOP_PERCENT"] = "1"
# new_env["GGPO_OOP_PERCENT"] = "1"
if idx == 0:
new_env["GGPO_NETWORK_JAM_DELAY"] = "500"
# else: new_env["GGPO_NETWORK_DELAY"] = "100"
return subprocess.Popen(cmd, shell=True, env=new_env)

Expand Down

0 comments on commit 78dbfbc

Please sign in to comment.